Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py3k: don't attempt to decode str objects #60

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions marrow/mailer/transport/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,11 @@ def deliver(self, message):
def send_with_smtp(self, message):
try:
sender = str(message.envelope)
recipients = message.recipients.string_addresses
recipients = [addr.decode('utf-8') for addr in message.recipients.string_addresses]
if hasattr(str, "decode"):
# don't attempt to utf-8-decode strings in Python 3
recipients = [addr.decode('utf-8') for addr in message.recipients.string_addresses]
else:
recipients = message.recipients.string_addresses
content = str(message)

self.connection.sendmail(sender, recipients, content)
Expand Down