How to send utf-8 mail in Python 3?


P

Peter Kleiweg

I try to send e-mail from Python 3.1.1

Encoding as iso-8859-1 goes fine.
But encoding as utf-8 doesn't work.
What am I doing wrong?


Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

H=E9Traceback (most recent call last):
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 269, in set_charset
cte(self)
TypeError: 'str' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/opt/Python-3/lib/python3.1/email/mime/text.py", line 30, in __init__
self.set_payload(_text, _charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 234, in set_payload
self.set_charset(charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 271, in set_charset
self._payload = charset.body_encode(self._payload)
File "/my/opt/Python-3/lib/python3.1/email/charset.py", line 380, in body_encode
return email.base64mime.body_encode(string)
File "/my/opt/Python-3/lib/python3.1/email/base64mime.py", line 94, in body_encode
enc = b2a_base64(s[i:i + max_unencoded]).decode("ascii")
TypeError: must be bytes or buffer, not str
 
Ad

Advertisements

P

Peter Kleiweg

Peter Kleiweg schreef op de 5e dag van de lentemaand van het jaar 2010:
I try to send e-mail from Python 3.1.1

Encoding as iso-8859-1 goes fine.
But encoding as utf-8 doesn't work.
What am I doing wrong?


More weird behaviour:

Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

SMOp
Traceback (most recent call last):
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 269, in set_charset
cte(self)
TypeError: 'str' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/opt/Python-3/lib/python3.1/email/mime/text.py", line 30, in __init__
self.set_payload(_text, _charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 234, in set_payload
self.set_charset(charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 271, in set_charset
self._payload = charset.body_encode(self._payload)
File "/my/opt/Python-3/lib/python3.1/email/charset.py", line 382, in body_encode
return email.quoprimime.body_encode(string)
File "/my/opt/Python-3/lib/python3.1/email/quoprimime.py", line 176, in body_encode
if line.endswith(CRLF):
TypeError: expected an object with the buffer interface
 
Ad

Advertisements

P

Peter Kleiweg

Peter Kleiweg schreef op de 5e dag van de lentemaand van het jaar 2010:
I try to send e-mail from Python 3.1.1

Encoding as iso-8859-1 goes fine.
But encoding as utf-8 doesn't work.
What am I doing wrong?

More weird behaviour:

Python 3.1.1 (r311:74480, Oct 2 2009, 11:50:52)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64

SMOp
Traceback (most recent call last):
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 269, in set_charset
cte(self)
TypeError: 'str' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/my/opt/Python-3/lib/python3.1/email/mime/text.py", line 30, in __init__
self.set_payload(_text, _charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 234, in set_payload
self.set_charset(charset)
File "/my/opt/Python-3/lib/python3.1/email/message.py", line 271, in set_charset
self._payload = charset.body_encode(self._payload)
File "/my/opt/Python-3/lib/python3.1/email/charset.py", line 382, in body_encode
return email.quoprimime.body_encode(string)
File "/my/opt/Python-3/lib/python3.1/email/quoprimime.py", line 176, in body_encode
if line.endswith(CRLF):
TypeError: expected an object with the buffer interface
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top