python实现邮件发送功能
import smtplib import email.mime.multipart import email.mime.text def send_email(receiver,content): msg = email.mime.text.MIMEText(content, ‘html‘, ‘utf-8‘) msg[‘from‘] = ‘‘ # 从该邮箱发送 msg[‘to‘] = receiver # 发送到该邮箱 msg[‘subject‘] = ‘Python自动邮件‘ smtpSever = ‘smtp.qq.com‘ # 163邮箱的smtp Sever地址 smtpPort = ‘25‘ # 开放的端口 sqm = ‘acsinwaqcutkbbha‘ # 在登录smtp时需要login中的密码应当使用授权码而非账户密码 smtp = smtplib.SMTP() # 服务器连接并登陆 smtp.connect(smtpSever, smtpPort) smtp.login(msg[‘from‘], sqm) # 发邮件 smtp.sendmail(msg[‘from‘], msg[‘to‘], str(msg)) print(str(msg)) smtp.quit() content="tester" send_email("",content)
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16