From 2542870f598cfec9b9aec3de5d3c603dbddf3865 Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 24 Nov 2009 20:43:33 +0000 Subject: [PATCH] Allow non-admin email addresses as envelope sender. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4391 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/roundup/mailer.py b/roundup/mailer.py index 171ec11..453a1de 100644 --- a/roundup/mailer.py +++ b/roundup/mailer.py @@ -177,17 +177,22 @@ class Mailer: content = '\n'.join(traceback.format_exception(*sys.exc_info())) self.standard_message(to, subject, content) - def smtp_send(self, to, message): + def smtp_send(self, to, message, sender=None): """Send a message over SMTP, using roundup's config. Arguments: - to: a list of addresses usable by rfc822.parseaddr(). - message: a StringIO instance with a full message. + - sender: if not 'None', the email address to use as the + envelope sender. If 'None', the admin email is used. """ + + if not sender: + sender = self.config.ADMIN_EMAIL if self.debug: # don't send - just write to a file open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' % - (self.config.ADMIN_EMAIL, + (sender, ', '.join(to), message)) else: # now try to send the message @@ -195,7 +200,7 @@ class Mailer: # send the message as admin so bounces are sent there # instead of to roundup smtp = SMTPConnection(self.config) - smtp.sendmail(self.config.ADMIN_EMAIL, to, message) + smtp.sendmail(sender, to, message) except socket.error, value: raise MessageSendError("Error: couldn't send email: " "mailhost %s"%value) -- 2.30.2