[Remail] [patch v2 06/11] remail: Unify send_mail()

Thomas Gleixner tglx at linutronix.de
Sun Jun 18 22:13:48 CEST 2023


No need for two functions.

Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
---
 remail/mail.py |   23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

--- a/remail/mail.py
+++ b/remail/mail.py
@@ -106,11 +106,16 @@ import re
     server.send_message(msg, sender, [to])
     server.quit()
 
-def msg_deliver(msg, account, mfrom, sender, use_smtp):
+def send_mail(msg, account, mfrom, sender, listheaders, use_smtp):
     '''
-    Deliver the message. Replace or set the mandatory headers, sanitize
-    and order them properly to make gmail happy.
+    Send mail to the account. Make sure that the message is correct and all
+    required headers and only necessary headers are in the outgoing mail.
     '''
+
+    # Add the list headers
+    for key, val in listheaders.items():
+        msg_set_header(msg, key, val)
+
     msg_set_header(msg, 'From', encode_addr(mfrom))
     msg_set_header(msg, 'To', encode_addr(account.addr))
     msg_set_header(msg, 'Return-path', sender)
@@ -128,18 +133,6 @@ import re
     else:
         print(msg.as_string())
 
-def send_mail(msg_out, account, mfrom, sender, listheaders, use_smtp):
-        '''
-        Send mail to the account. Make sure that the message
-        is correct and all required headers and only necessary
-        headers are in the outgoing mail.
-        '''
-        # Add the list headers
-        for key, val in listheaders.items():
-            msg_out[key] = val
-
-        msg_deliver(msg_out, account, mfrom, sender, use_smtp)
-
 # Minimal check for a valid email address
 re_mail = re.compile('^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$')
 



More information about the Remail mailing list