smtp.py:
#!/usr/bin/python
-- coding: utf-8 --
import smtplib
from email.mime.text import MIMEText
from email.header import Header
mail_host=“smtp.qq.com”#设置的邮件服务器host必须是发送邮箱的服务器,与接收邮箱无关。
mail_user="1053451294@qq.com"#qq邮箱登陆名
mail_pass=“bsindkdyponnbcac” #开启stmp服务的时候并设置的授权码,注意!不是QQ密码。
sender=‘1053451294@qq.com’#发送方qq邮箱
receivers=[‘1125085002@qq.com’]#接收方qq邮箱
message=MIMEText(‘your room temperature has reached 27!’,‘plain’,‘utf-8’)
message[‘From’]=Header(“maweiye”,‘utf-8’) #设置显示在邮件里的发件人
message[‘To’]=Header(“liup