python发送邮件

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 10:17   83   0
import smtplib
from email.mime.text import MIMEText

SMTPserver = 'smtp.163.com'  #邮箱服务器
sender = 'qaqzz5123@163.com' #发送邮箱
password = "hlx951118nb"     #密码

message = 'I send a message by Python. 你好'
msg = MIMEText(message)

msg['Subject'] = 'Test Email by Python'
msg['From'] = 'sender'
msg['To'] = 'destination'

mailserver = smtplib.SMTP(SMTPserver, 25)
mailserver.login(sender, password)
mailserver.sendmail(sender, [sender], msg.as_string())
mailserver.quit()
print ('send email success')
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP