diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2023-06-18 15:45:36 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2023-06-20 23:43:23 +0200 |
commit | 2760a2d671293cdad53db16fd921796f50773121 (patch) | |
tree | 4eebfa73694afc92d920d6034258d447ff0bbc2f | |
parent | 759dd19c9e374a9330929259e33e037994776ce2 (diff) | |
download | remail-2760a2d671293cdad53db16fd921796f50773121.tar.gz |
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>
-rw-r--r-- | remail/mail.py | 5 | ||||
-rw-r--r-- | remail/maillist.py | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/remail/mail.py b/remail/mail.py index 8e047e9..02c278f 100644 --- a/remail/mail.py +++ b/remail/mail.py @@ -75,7 +75,7 @@ def msg_copy_headers(msgout, msg, headers): if 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 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 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 if use_smtp: send_smtp(msgout, account.addr, sender) diff --git a/remail/maillist.py b/remail/maillist.py index 3f7e4ab..2bd9dd8 100644 --- a/remail/maillist.py +++ b/remail/maillist.py @@ -67,7 +67,8 @@ class maillist(object): Only ever use for admin mails which contain no content! ''' 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): ''' @@ -89,7 +90,8 @@ class maillist(object): try: msg_out = self.encrypt(msg_plain, account) 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: ''' GPG and S/MIME exceptions are not fatal. If they happen |