您好,登录后才能下订单哦!
#163邮箱发送邮件
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
my_sender = 'XXXXX@163.com'
my_pass = 'XXXXX'
my_user = 'XXXX@qq.com'
def mail():
ret = True
try:
mail_msg = "Python 邮件发送测试"
msg = MIMEText(mail_msg, 'html', 'utf-8')
msg['From'] = formataddr(["Rocky", my_sender])
msg['To'] = formataddr(["Amy", my_user])
msg['Subject'] = '邮件主题'
'''
#邮箱 发件服务器 非SSL协议端口 SSL协议端口
#163 smtp .163.com 25 465 / 587
#qq smtp.qq.com 25 465 / 587
'''
server = smtplib.SMTP_SSL("smtp.163.com", 465)
server.login(my_sender, my_pass)
server.sendmail(my_sender, [my_user, ], msg.as_string())
server.quit()
except smtplib.SMTPException:
ret=False
return ret
ret = mail()
if ret:
print("邮件发送成功")
else:
print("邮件发送失败")
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。