Permalink
Browse files

Probable fix for #29.

  • Loading branch information...
1 parent 6e240e6 commit bde984be858dfc1f97897ebb3cadf06f98060bb5 @amcgregor amcgregor committed Nov 23, 2011
Showing with 8 additions and 3 deletions.
  1. +3 −0 marrow/mailer/message.py
  2. +5 −3 marrow/mailer/transport/smtp.py
View
@@ -109,6 +109,9 @@ def id(self):
def envelope(self):
"""Returns the address of the envelope sender address (SMTP from, if
not set the sender, if this one isn't set too, the author)."""
+ if not self.sender and not self.author:
+ raise ValueError("Unable to determine message sender; no author or sender defined.")
+
return self.sender or self.author[0]
@property
@@ -109,10 +109,12 @@ def deliver(self, message):
raise TransportExhaustedException()
def send_with_smtp(self, message):
+ sender = bytes(message.envelope)
+ recipients = message.recipients.string_addresses
+ content = bytes(message)
+
try:
- sender = bytes(message.envelope)
- recipients = message.recipients.string_addresses
- self.connection.sendmail(sender, recipients, bytes(message))
+ self.connection.sendmail(sender, recipients, content)
self.sent += 1
except SMTPSenderRefused as e:

0 comments on commit bde984b

Please sign in to comment.