I have the sample script that uses the smtplib module
that is available at python.org.
How can I use this to send an attachment?
By brute force... You create the proper MIME headers to identify
the presence of an attachment; you use the proper module(s) to convert
the file of the attachment into an SMTP safe format (Base64?); you copy
the attachment, with proper MIME boundary markers, into the body of the
email.
No doubt there is a simpler, more automated method, but by
knowing what goes into the process, you can get more control over it.
smtplib is merely the low level interface between a sending
client and the receiving smtp daemon. The "msg" argument has to be a
fully formed message with all headers and body.
Check mimetools, mimify, and email modules.
--