标签:ESS 邮件 smtplib evel 内容 mail pytho import highlight
import smtplib from email.mime.text import MIMEText subject = "标题" # 邮件的主题 content = "测试" # 邮件的内容 sender = "1548429568@qq.com" # 发件人 password = "qnrwndesjxmmijce" # 刚才我们在QQ邮箱里设置的授权密码 receiver = "3235403488@qq.com" # 收件人 message = MIMEText(content, "plain", "utf-8") # 内容,格式,编码格式 message["From"] = sender # 发送邮箱 message["To"] = receiver # 接收邮箱 message["Subject"] = subject # 标题 # message = ‘\n‘.join([‘From: {}‘.format(sender), ‘To: {}‘.format(receiver), ‘Subject: {}‘.format(subject), ‘‘, content]) # smtp = smtplib.SMTP() # 普通的邮件发送形式 smtp = smtplib.SMTP_SSL("smtp.qq.com", 465) # QQ邮箱的SMTP服务器(端口465或587) smtp.set_debuglevel(1) # 用set_debuglevel(1)就可以打印出和SMTP服务器交互的所有信息 smtp.login(sender, password) # 登录SMTP服务器,输入发送邮箱和密码 smtp.sendmail(sender, receiver, message.as_string()) smtp.quit() smtp.close()
标签:ESS 邮件 smtplib evel 内容 mail pytho import highlight
原文地址:https://www.cnblogs.com/liuhaidon/p/12146314.html