email.py 邮件发送

发布时间:2019-03-12 00:44:30编辑:auto阅读(2255)

     1 import smtplib
     2 from email.mime.text import MIMEText 
     3 msg = MIMEText('发送内容,自行编辑','plain','utf-8')
     4 from_addr = '1160780114@qq.com'
     5 #授权码
     6 from_pwd ="ozgdpapqwyoxghfi"
     7 to_addr= '1160780114@qq.com'
     8 
     9 smtp_srv = "smtp.qq.com"
    10 
    11 try:
    12 srv = smtplib.SMTP_SSL(smtp_srv.encode(),465)
    13 srv.login(from_addr,from_pwd)
    14 srv.sendmail(from_addr,[to_addr],msg.as_string())
    15 srv.quit()
    16 except Exception as e:
    17 print(e)

    这段代码 能简单实现邮件发送 ,只是qq邮箱的发送

关键字