python 发送邮件

#发邮件的库import smtplib#邮件文本from email.mime.text import MIMEText#SMTP服务器SMTPServer = "smtp.163.com"#发邮件的地址sender = ""#发送者邮箱的密码passwd = "12345678"#设置发送的内容message = "点开说明你承认我帅了,嘿嘿~"#转换成邮件文本msg = MIMEText(message)#标题msg["Subject"] = "来自帅哥的问候"#发送者msg["From"] = sender#创建SMTP服务器mailServer = smtplib.SMTP(SMTPServer, 25)#登陆邮箱mailServer.login(sender, passwd)#发送邮件mailServer.sendmail(sender, [""], msg.as_string())#退出邮箱mailServer.quit()

相关推荐