string payload expected: <type 'list'> error

MRAB python at
Thu Nov 26 21:33:59 CET 2009

Ramdas wrote:
> Dear all,
> I believe this is an error which was fixed in Python 2.3 itself. But I
> am running Python 2,5.2 and error keeps on cropping up.
> Here is my code to construct emails . It works perfectly when I dont
> have any attachments. Please find my code at
> However when I try constructing with attachments it crashes with this
> error string payload expected: <type 'list'> error.
> Going through the trace error I discover that as I call the function
> msg.as_string, the function . _handle_text(self, msg) expects a string
> object but I am generating list object. Can someone advise what I need
> to code to parse series of attachments into an email.
> Help appreciated

I've been looking at the example in the Python 2.6.2 documentation. It
looks like you should have:

     msg1.add_header('Content-Disposition', 'attachment', filename=filename)

More information about the Python-list mailing list