Chris Withers wrote:
> Max M wrote:
>> From the docs:
>>
>> """
>> The payload is either a string in the case of simple message objects
>> or a list of Message objects for MIME container documents (e.g.
>> multipart/* and message/rfc822)
>> """
>
> Where'd you find that? I must have missed it i
Max M wrote:
> From the docs:
>
> """
> The payload is either a string in the case of simple message objects or
> a list of Message objects for MIME container documents (e.g. multipart/*
> and message/rfc822)
> """
Where'd you find that? I must have missed it in my digging :-S
> Message objec
Chris Withers wrote:
> Okay, more out of desperation than anything else, lets try this:
>
> from email.Charset import Charset,QP
> from email.MIMEText import MIMEText
> from StringIO import StringIO
> from email import Generator,Message
> Generator.StringIO = Message.StringIO = StringIO
> charset
Chris Withers wrote:
> Chris Withers wrote:
>> print msg.as_string()
>>
>> MIME-Version: 1.0
>> Content-Type: text/plain; charset; charset="utf-8"
> ^^^
> Actually, even this isn't correct as you can see above...
>
>> charset = Charset('utf-8')
>> msg = MIMEText('',
Chris Withers wrote:
> Has no-one ever successfully generated a correctly formatted email with
> email.MIMEText where the message includes non-ascii characters?!
I'm guessing not ;-)
Well, I think I have a winner, but it required me to subclass MIMEText:
from email.Charset import Charset,QP
fro
Chris Withers wrote:
> print msg.as_string()
>
> MIME-Version: 1.0
> Content-Type: text/plain; charset; charset="utf-8"
^^^
Actually, even this isn't correct as you can see above...
> charset = Charset('utf-8')
> msg = MIMEText('','plain',None)
> msg.set_payload(u
Chris Withers wrote:
> ...except it gets the transfer encoding wrong, which means Thunderbird
> shows =A3 instead of the pound sign that it should :-(
>
> ...this is down to a pretty lame bit of code in Encoders.py which
> basically checks for a unicode error *sigh*
OK, slight progress... here
Peter Otten wrote:
> Chris Withers wrote:
>
>> At worst, and most likely based on my past experience of (c)StringIO
>> being used to accumulate output, it won't make a jot of difference...
>
> What past experience?
>
StringIO.StringIO().write(unichr(128))
cStringIO.StringIO().write(uni
Peter Otten wrote:
> What past experience?
>
StringIO.StringIO().write(unichr(128))
cStringIO.StringIO().write(unichr(128))
> Traceback (most recent call last):
> File "", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode character u'\x80' in position
> 0: ordinal not in ra
Chris Withers wrote:
> At worst, and most likely based on my past experience of (c)StringIO
> being used to accumulate output, it won't make a jot of difference...
What past experience?
>>> StringIO.StringIO().write(unichr(128))
>>> cStringIO.StringIO().write(unichr(128))
Traceback (most recent
Chris Withers wrote:
> Steve Holden wrote:
>
>>> Is there a how-to for this anywhere? The email package's docs are
>>> short on examples involving charsets, unicode and the like :-(
>>>
>> Well, it would seem like the easiest approach is to monkey-patch the
>> use of cStringIO to StringIO as rec
Manlio Perillo wrote:
>
> The problem is simple: email package does not support well Unicode strings.
Really? All the character set support seems to indicate a fair bit of
thought went into this aspect, although it does appear that no-one
bothered to document it :-(
Chris
--
Simplistix - Con
Steve Holden wrote:
>> Is there a how-to for this anywhere? The email package's docs are short
>> on examples involving charsets, unicode and the like :-(
>>
> Well, it would seem like the easiest approach is to monkey-patch the use
> of cStringIO to StringIO as recommended and see if that fixes
Chris Withers ha scritto:
> [...]
>
> OK, but I fail to see how replacing one unicode error with another is
> any help... :-S
>
The problem is simple: email package does not support well Unicode strings.
For now I'm using this:
charset = "utf-8" # the charset to be used for email
class Head
Chris Withers wrote:
>
> Now, I want to know what I'm supposed to do when I have unicode source
> and want it to end up as either a text/plain or text/html mime part.
>
> Is there a how-to for this anywhere? The email package's docs are short
> on examples involving charsets, unicode and the like
Chris Withers wrote:
> Peter Otten wrote:
>
>>http://sourceforge.net/tracker/?func=detail&aid=1409455&group_id=5470&atid=105470
>>
>>>Now, is this change to Generator.py in error or am I doing something
>>>wrong?
>>
>>I'm not familiar enough with the email package to answer that.
>
>
> I'm hopin
Peter Otten wrote:
> http://sourceforge.net/tracker/?func=detail&aid=1409455&group_id=5470&atid=105470
>> Now, is this change to Generator.py in error or am I doing something
>> wrong?
>
> I'm not familiar enough with the email package to answer that.
I'm hoping someone around here is ;-)
>> If
Chris Withers wrote:
> The following piece of code is giving me issues:
>
> from email.Charset import Charset,QP
> from email.MIMEText import MIMEText
> charset = Charset('utf-8')
> charset.body_encoding = QP
> msg = MIMEText(
> u'Some text with chars that need encoding: \xa3',
> 'plain
Manlio Perillo wrote:
> Try with:
>
> msg = MIMEText(
> u'Some text with chars that need encoding: \xa3',
> _charset='utf-8',
> )
>
>
> and you will obtain the error:
>
> Traceback (most recent call last):
> File "", line 3, in -toplevel-
> _charset='utf-8',
> File "C:\Py
Chris Withers ha scritto:
> Hi All,
>
> The following piece of code is giving me issues:
>
> from email.Charset import Charset,QP
> from email.MIMEText import MIMEText
> charset = Charset('utf-8')
> charset.body_encoding = QP
> msg = MIMEText(
> u'Some text with chars that need encoding: \xa3
Hi All,
The following piece of code is giving me issues:
from email.Charset import Charset,QP
from email.MIMEText import MIMEText
charset = Charset('utf-8')
charset.body_encoding = QP
msg = MIMEText(
u'Some text with chars that need encoding: \xa3',
'plain',
)
msg.set_charset(chars
21 matches
Mail list logo