yangyangchunchun

__author__ = \'Administrator\'
from email.mime.text import MIMEText #构造邮件
import smtplib #发送邮件

#第一步构造邮件
msg = MIMEText(_text = "hello", _subtype=\'plain\', _charset=\'utf-8\')
msg["subject"] = "卢阳阳的第一封邮件"
msg["from"] = "847767723@qq.com"
msg["to"] = "yangchun_lu@daydao.com"


#连接邮件服务器
smtp = smtplib.SMTP_SSL(host=\'smtp.qq.com\', port=465) #qq邮箱的发送邮件的服务器为smtp.qq.com por,使用SSL,端口号:465

#登录邮箱
smtp.login("847767723@qq.com","tvwldevdeajlbefi") #第三方客户端如Foxmail客户端登录qq邮箱发送,密码为授权码(这里相当与第三方客户端登录)

#发送邮件
smtp.sendmail("847767723@qq.com","yangchun_lu@daydao.com",msg.as_string())

#关闭邮件服务器连接
smtp.quit()

 

分类:

技术点:

相关文章:

  • 2021-05-22
  • 2022-12-23
  • 2021-06-06
  • 2021-04-10
  • 2021-09-23
  • 2022-01-02
猜你喜欢
  • 2021-04-28
  • 2021-06-13
  • 2022-12-23
  • 2021-11-18
  • 2021-08-29
  • 2021-12-13
相关资源
相似解决方案