get_payload problem with large mail attachments

Peter Otten __peter__ at web.de
Fri Oct 14 06:53:39 EDT 2005


hungryblank at gmail.com wrote:

> I'm having troubles with a script that uses the get_payload function.
> My script just works perfectly if I use it with attachment up to 8 Mb.
> If the attachment are more than 8 Mb large, the script exits with a
> TypeError exception.
> IMHO when get_payload try to convert the attachment in a single string
> it occours in some size limit.
> How can I fix it?

> Traceback (most recent call last):
> File "/usr/local/sbin/mailbox2home.py", line 44, in ?
> fp.write(part.get_payload(decode=1))
> TypeError: argument 1 must be string or read-only buffer, not None

None seems to be the expected result of get_payload(decode=1) for multipart
parts.

>         if part.get_content_maintype() == 'multipart':
>             continue

Could it be that your test for multipart isn't correct? I would try

if part.is_multipart():
    continue

Peter




More information about the Python-list mailing list