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: Sending mail over SMTP tries to decode str objects #59

Closed
nphilipp opened this issue Feb 26, 2016 · 2 comments
Closed

Py3k: Sending mail over SMTP tries to decode str objects #59

nphilipp opened this issue Feb 26, 2016 · 2 comments
Labels
1.bug An error has been encountered that is preventing utilization. transport:smtp

Comments

@nphilipp
Copy link

>>> from marrow.mailer import Mailer, Message
>>> mailer = Mailer({'transport': {'use': 'smtp', 'tls': 'no', 'host': 'mail.tiptoe.de'}})
>>> msg = Message(author='[email protected]', to='[email protected]', subject='Test')
>>> mailer.start(); mailer.send(msg); mailer.stop()
<[email protected]> DEFERRED AttributeError
Traceback (most recent call last):
  File "/home/nils/.virtualenvs/igl-py3k/lib/python3.4/site-packages/marrow/mailer/transport/smtp.py", line 115, in send_with_smtp
    recipients = [addr.decode('utf-8') for addr in message.recipients.string_addresses]
  File "/home/nils/.virtualenvs/igl-py3k/lib/python3.4/site-packages/marrow/mailer/transport/smtp.py", line 115, in <listcomp>
    recipients = [addr.decode('utf-8') for addr in message.recipients.string_addresses]
AttributeError: 'str' object has no attribute 'decode'
    Mailer(manager=ImmediateManager, transport=SMTPTransport)

The code assumes an UTF-8 encoded, Python 2 str object which needs to be decoded into a unicode object. In Python 3, this is unnecessary.

nphilipp added a commit to nphilipp/marrow.mailer that referenced this issue Feb 26, 2016
Python 3 `str` objects are Unicode already and don't need decoding.

marrow#59
@kute
Copy link
Contributor

kute commented Sep 14, 2016

how to solve this in py3 ?

@amcgregor amcgregor added 1.bug An error has been encountered that is preventing utilization. transport:smtp labels Apr 22, 2020
@amcgregor
Copy link
Member

This was likely resolved long, long ago, with a PR from Nando.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.bug An error has been encountered that is preventing utilization. transport:smtp
Projects
None yet
Development

No branches or pull requests

3 participants