smtp mail with attachment

Sandipan Gangopadhyay sandipan at
Tue Feb 6 09:35:10 EST 2001

AFAIK, and I could be ignorant, but you just have to construct the mail with
With content-type as multi-part (because the email will have more than one
part (itself) - the attachment(s))
And then, in one of the parts, put in the attachment after declaring its
Please note that if you are going to need to send binary attachments, base64
will come in use to encode it first. As in:
Content-Type: whatever/whatever
Content-Transfer-Encoding: base64
You can use smtplib to send the mime you have built then.

Also, you can have other parts of the email refer to this attachment by
giving it an identifier (URL sort of)

Works fine on both Unix and Windows.

HTH. Regards,

----- Original Message -----
From: "Scott Hathaway" <slhath at>
Newsgroups: comp.lang.python
To: <python-list at>
Sent: Tuesday, February 06, 2001 7:07 PM
Subject: smtp mail with attachment

> How do I send an email with an attachment with python (I need a cross
> platform solution for Windows and Unix)?
> Thanks,
> Scott
> --

More information about the Python-list mailing list