sending a file as an attachment with smtplib

Peter Hansen peter at
Wed Jul 28 12:44:52 CEST 2004

Stephen Boulet wrote:

> Is it possible to send a file as an attachment using smtplib?

Of course, but smtplib is just for sending raw data, not for
formatting the message itself.  For that you need the "email"
module.  Look in the docs for it, and specifically for the
examples, which include "Here's an example of how to send a
MIME message containing a bunch of family pictures that may
be residing in a directory:"


More information about the Python-list mailing list