简单实现
用了2个模块, smtplib 主要的三个函数login ,sendmial ,close
SMTP.login(user, password)
SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options])
https://docs.python.org/2/library/smtplib.html#smtp-example
#!/usr/bin/python
#coding:utf-8
import smtplib
from email.mime.text import MIMEText
user=‘22@qq.com‘ passwd=‘xxx‘
to=‘xxx@qq.com‘
msg=MIMEText("早上好")
msg["Subject"] = 	‘hi,man‘
msg[‘From‘]	=	user
msg[‘to‘]	=	to
print msg.as_string()
s=smtplib.SMTP(‘smtp.qq.com‘)
s.login(user,passwd)
s.sendmail(user,to,msg.as_string())
s.close()
发中文,必须在之前加入 #coding:utf-8 ,否则会报错。
原文:http://www.cnblogs.com/gqdw/p/3955962.html