diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2023-06-18 18:18:53 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2023-06-20 23:43:23 +0200 |
commit | 79aa834870827f802b314b3dd238dbddf25abb69 (patch) | |
tree | c948ac5bb50a0bbf947c6c727cb00639658e628d | |
parent | c3b13e47f7fe99f3381726fd11dd317cbcc6622e (diff) | |
download | remail-79aa834870827f802b314b3dd238dbddf25abb69.tar.gz |
remail: Unify send_mail()
No need for two functions.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | remail/mail.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/remail/mail.py b/remail/mail.py index 4ec3eaa..5e178a1 100644 --- a/remail/mail.py +++ b/remail/mail.py @@ -106,11 +106,16 @@ def send_smtp(msg, to, sender): 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 @@ def msg_deliver(msg, account, mfrom, sender, use_smtp): 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,})+$') |