Skip to content

Commit

Permalink
Probable fix for #29.
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Nov 23, 2011
1 parent 6e240e6 commit bde984b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions marrow/mailer/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions marrow/mailer/transport/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bde984b

Please sign in to comment.