Mercurial > p > roundup > code
diff roundup/mailer.py @ 4287:630a20c51345
Allow non-admin email addresses as envelope sender.
| author | Stefan Seefeld <stefan@seefeld.name> |
|---|---|
| date | Tue, 24 Nov 2009 20:43:33 +0000 |
| parents | 2f4cee0e31e2 |
| children | 7a6c5c117879 |
line wrap: on
line diff
--- a/roundup/mailer.py Tue Nov 24 20:39:51 2009 +0000 +++ b/roundup/mailer.py Tue Nov 24 20:43:33 2009 +0000 @@ -177,17 +177,22 @@ 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 @@ # 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)
