[Email-SIG] Ensuring 7 bit encoding

Mark Sapiro mark at msapiro.net
Fri Aug 28 02:42:05 CEST 2009


Nicholas Cole wrote:
>
>What do I need to do to ensure that emails are generated only in 7,
>not 8-bit encodings?  I assume that I need to use
>email.charset.add_charset , but can't quite work out what incantation
>to give it.  Does anyone have any pointers?


I'm not sure what it is you're asking. Does this answer your question?

>>> import email.message
>>> m = email.message.Message()
>>> m.set_payload("""A few lines
... of 7-bit text
...
... No high bit characters.
... """, 'us-ascii')
>>> print m.as_string()
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

A few lines
of 7-bit text

No high bit characters.

>>>


-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Email-SIG mailing list