from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr,formataddr
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage # 发送普通文字
def _format_addr(s):
name,addr = parseaddr(s)
return formataddr((Header(name,'utf-8').encode(),addr)) from_addr = '834424581@qq.com'
password = 'rlu********bfe'#邮箱授权码
to_addr = '3153324684@qq.com'
smtp_sever = 'smtp.qq.com'
msg = MIMEText('我是自动发的,哈哈哈','plain','utf-8')
msg['From']=_format_addr('福龙 <%s>' % from_addr)
msg['To']=_format_addr('小号 <%s>' % to_addr)
msg['Subject']=Header('每日汇报','utf-8').encode()
server = smtplib.SMTP_SSL(smtp_sever,465,timeout=10)
server.set_debuglevel(0)
server.login(from_addr,password)
server.sendmail(from_addr,[to_addr],msg.as_string())
server.quit()