#!/usr/bin/env python
import smtplib
import string
HOST = "smtp.sina.cn"
SUBJECT = "Test mail from python"
TO = "gswcfl2013@sina.cn"
FROM = "gswcfl2013@sina.cn"
text = "python rules them all!!!"
BODY = string.join((
"From:%s" % FROM,
"To:%s" % TO,
"subject:%s" % SUBJECT,
"",
text
),"\r\n")
server=smtplib.SMTP()
server.connect(HOST,25)
server.starttls()
server.login("gswcfl2013@sina.cn","******")
server.sendmail(FROM,TO,BODY)
server.quit()
本文转自 gswljy 51CTO博客,原文链接:http://blog.51cto.com/guoshiwei/1924261