From 22a964f0f5b266d8906074916f7571a5177445b7 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Sat, 15 Nov 2025 13:26:15 +0100 Subject: [PATCH] Fixes in sendmail --- paramecio2/libraries/sendmail.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/paramecio2/libraries/sendmail.py b/paramecio2/libraries/sendmail.py index 116dd2f..8dc4dc3 100644 --- a/paramecio2/libraries/sendmail.py +++ b/paramecio2/libraries/sendmail.py @@ -29,6 +29,7 @@ from email.mime.base import MIMEBase from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from email.utils import formataddr import ssl as ssl_module import sys @@ -129,7 +130,7 @@ class SendMail: return True - def send(self, from_address, to_address: list, subject, message, content_type='plain', attachments=[]): + def send(self, from_address, to_address: list, subject, message, content_type='plain', attachments=[], reply_to=()): """ Method that send email With this method you can send email to multiple address, html, and add attachments to email @@ -147,6 +148,10 @@ class SendMail: if not self.connect(): return False + if len(reply_to)==0: + reply_to=(from_address, from_address) + + COMMASPACE=', ' if len(attachments)==0: @@ -154,6 +159,9 @@ class SendMail: msg=MIMEText(message, content_type) msg['Subject']=subject + + msg['Reply-To']=formataddr(reply_to) + msg['From']=from_address msg['To']=COMMASPACE.join(to_address) @@ -169,6 +177,9 @@ class SendMail: outer=MIMEMultipart() outer['Subject']=subject + + msg['Reply-To']=formataddr(reply_to) + outer['From']=from_address outer['To']=COMMASPACE.join(to_address)