Reading EmailMessage from file
jon+usenet at unequivocal.eu
Mon Jul 16 06:35:21 EDT 2018
On 2018-07-16, Skip Montanaro <skip.montanaro at gmail.com> wrote:
>> What are you actually trying to do? You're talking like you're trying
>> to read an existing RFC822 email-with-headers from a file, but you're
>> showing code that creates a new email with body content set from
>> a file, which is a completely different thing.
> Yes, that's exactly what I'm trying to do.
That's not entirely helpful; I said I couldn't tell what you were
trying to do, was it (a) or (b), and you've replied "Yes".
> A bit more context... I'm trying to port SpamBayes from Python 2 to
> Python 3. The file I attached which failed to come through was
> exactly what you suggested, an email in a file. That is what the
> example from the 3.7 docs suggested I should be able to do
If you are actually trying to read an RFC822 message-with-headers
from a file, which the above suggests you are, then the example has
nothing to do with your situation and as has been suggested you want
the email.message_from_binary_file(fp) function (the documentation
for which is cunningly hidden near the bottom of
More information about the Python-list