示例代码:
#coding=utf-8
import smtplib
from email.mime.text import MIMEText
msg_from='297321010@qq.com'
passwd='*****' #此处不是qq密码,是申请开通POP3/SMTP 服务时,提供的授权码
msg_to='1422456765@qq.com'
subject = "python邮件测试"
content = "这是我使用python smtplib及email模块发送的邮件"
msg = MIMEText(content)
msg['Subject'] = subject
msg['From'] = msg_from
msg['To'] = msg_to
#try:
s = smtplib.SMTP_SSL("smtp.qq.com",465)
s.login(msg_from, passwd)
s.sendmail(msg_from, msg_to, msg.as_string())
print ("发送成功")