mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-25 13:52:38 +01:00
remail: Unify send_mail()
No need for two functions. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
c3b13e47f7
commit
79aa834870
1 changed files with 8 additions and 15 deletions
|
@ -106,11 +106,16 @@ def send_smtp(msg, to, sender):
|
||||||
server.send_message(msg, sender, [to])
|
server.send_message(msg, sender, [to])
|
||||||
server.quit()
|
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
|
Send mail to the account. Make sure that the message is correct and all
|
||||||
and order them properly to make gmail happy.
|
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, 'From', encode_addr(mfrom))
|
||||||
msg_set_header(msg, 'To', encode_addr(account.addr))
|
msg_set_header(msg, 'To', encode_addr(account.addr))
|
||||||
msg_set_header(msg, 'Return-path', sender)
|
msg_set_header(msg, 'Return-path', sender)
|
||||||
|
@ -128,18 +133,6 @@ def msg_deliver(msg, account, mfrom, sender, use_smtp):
|
||||||
else:
|
else:
|
||||||
print(msg.as_string())
|
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
|
# Minimal check for a valid email address
|
||||||
re_mail = re.compile('^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$')
|
re_mail = re.compile('^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue