mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-24 21:32:39 +01:00
remail: Check outgoing mails for defects
EmailMessage.defects allows to inspect outgoing mails for defects. If found report them in logging. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
759dd19c9e
commit
2760a2d671
2 changed files with 8 additions and 3 deletions
|
@ -75,7 +75,7 @@ def msg_copy_headers(msgout, msg, headers):
|
||||||
if val:
|
if val:
|
||||||
msgout[key] = val
|
msgout[key] = val
|
||||||
|
|
||||||
def send_mail(msg, account, mfrom, sender, listheaders, use_smtp):
|
def send_mail(msg, account, mfrom, sender, listheaders, use_smtp, logger):
|
||||||
'''
|
'''
|
||||||
Send mail to the account. Make sure that the message is correct and all
|
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.
|
required headers and only necessary headers are in the outgoing mail.
|
||||||
|
@ -114,6 +114,9 @@ def send_mail(msg, account, mfrom, sender, listheaders, use_smtp):
|
||||||
# Set unixfrom with the current date/time
|
# Set unixfrom with the current date/time
|
||||||
msgout.set_unixfrom('From remail ' + time.ctime(time.time()))
|
msgout.set_unixfrom('From remail ' + time.ctime(time.time()))
|
||||||
|
|
||||||
|
if len(msgout.defects):
|
||||||
|
logger.log_warn('Outgoing email has defects: %s\n' %msgout.defects)
|
||||||
|
|
||||||
# Send it out
|
# Send it out
|
||||||
if use_smtp:
|
if use_smtp:
|
||||||
send_smtp(msgout, account.addr, sender)
|
send_smtp(msgout, account.addr, sender)
|
||||||
|
|
|
@ -67,7 +67,8 @@ class maillist(object):
|
||||||
Only ever use for admin mails which contain no content!
|
Only ever use for admin mails which contain no content!
|
||||||
'''
|
'''
|
||||||
send_mail(msg, account, self.config.listaddrs.owner,
|
send_mail(msg, account, self.config.listaddrs.owner,
|
||||||
self.config.listaddrs.bounce, {}, self.use_smtp)
|
self.config.listaddrs.bounce, {}, self.use_smtp,
|
||||||
|
self.logger)
|
||||||
|
|
||||||
def encrypt(self, msg_plain, account):
|
def encrypt(self, msg_plain, account):
|
||||||
'''
|
'''
|
||||||
|
@ -89,7 +90,8 @@ class maillist(object):
|
||||||
try:
|
try:
|
||||||
msg_out = self.encrypt(msg_plain, account)
|
msg_out = self.encrypt(msg_plain, account)
|
||||||
send_mail(msg_out, account, mfrom, self.config.listaddrs.bounce,
|
send_mail(msg_out, account, mfrom, self.config.listaddrs.bounce,
|
||||||
self.config.listheaders, self.use_smtp)
|
self.config.listheaders, self.use_smtp, self.logger)
|
||||||
|
|
||||||
except (RemailGPGException, RemailSmimeException) as ex:
|
except (RemailGPGException, RemailSmimeException) as ex:
|
||||||
'''
|
'''
|
||||||
GPG and S/MIME exceptions are not fatal. If they happen
|
GPG and S/MIME exceptions are not fatal. If they happen
|
||||||
|
|
Loading…
Reference in a new issue