Skip to content

Commit e863810

Browse files
committed
Allow non-admin email addresses as envelope sender.
1 parent 029e4cd commit e863810

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

roundup/mailer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,30 @@ def exception_message(self):
177177
content = '\n'.join(traceback.format_exception(*sys.exc_info()))
178178
self.standard_message(to, subject, content)
179179

180-
def smtp_send(self, to, message):
180+
def smtp_send(self, to, message, sender=None):
181181
"""Send a message over SMTP, using roundup's config.
182182
183183
Arguments:
184184
- to: a list of addresses usable by rfc822.parseaddr().
185185
- message: a StringIO instance with a full message.
186+
- sender: if not 'None', the email address to use as the
187+
envelope sender. If 'None', the admin email is used.
186188
"""
189+
190+
if not sender:
191+
sender = self.config.ADMIN_EMAIL
187192
if self.debug:
188193
# don't send - just write to a file
189194
open(self.debug, 'a').write('FROM: %s\nTO: %s\n%s\n' %
190-
(self.config.ADMIN_EMAIL,
195+
(sender,
191196
', '.join(to), message))
192197
else:
193198
# now try to send the message
194199
try:
195200
# send the message as admin so bounces are sent there
196201
# instead of to roundup
197202
smtp = SMTPConnection(self.config)
198-
smtp.sendmail(self.config.ADMIN_EMAIL, to, message)
203+
smtp.sendmail(sender, to, message)
199204
except socket.error, value:
200205
raise MessageSendError("Error: couldn't send email: "
201206
"mailhost %s"%value)

0 commit comments

Comments
 (0)