On 28/09/06, Erik Johnson <ej <[EMAIL PROTECTED]>wellkeeper dot <"com>"@bag.python.org> wrote:
> #!/usr/bin/env python > > import smtplib > from email.MIMEText import MIMEText > from email.MIMEMultipart import MIMEMultipart > > > # GLOBAL DATA > #============= > MAIL_SERVER = 'your_server.com' > MAIL_SUBJECT = "Python.SMTP email test" > MAIL_TO = '[EMAIL PROTECTED]' > MAIL_FROM = "Python.SMTP email test" > > > # Create a text/plain message > > Body = """\ > This is intended to be the body of my email. The HTML below should not > be seen directly in the body but should be a separate attachment. > """ > > msg = MIMEMultipart() > msg['Subject'] = MAIL_SUBJECT > msg['From'] = MAIL_FROM > msg['To'] = MAIL_TO > msg.preamble = Body > > > html = """\ > <html> > <head> > <title>Sample HTML File</title> > </head> > > <body> > <h1>Can you see this?</h1> > <p>This is a short paragraph.</p> > </body> > > </html> > """ html_part = MIMEText(html, _subtype='html') html_part.add_header('Content-Disposition', 'attachment', filename='my_text.html') msg.attach(html_part) ># msg.attach(MIMEText(html, 'html')) > # print msg.as_string() > > > # Send the message via our own SMTP server, but don't include the > # envelope header. > smtp = smtplib.SMTP(MAIL_SERVER) > smtp.sendmail(MAIL_FROM, [MAIL_TO], msg.as_string()) > smtp.close() > # end of python script > -- http://mail.python.org/mailman/listinfo/python-list