""" python 发送邮件,用授权码 """ import smtplib from email.mime.text import MIMEText def send(): """ 发送邮件 :return: """ try: stmpserver163='smtp.163.com' stmpport=25 frommail='[email protected]' code163='geovindu' toemails=['[email protected]','[email protected]'] #创建邮件: msg=MIMEText('<h3>hi, how are you. send mail<h3>','html','utf-8') #邮件内容 msg['Subject'] = 'ICT 公益培训 考试日期通知' #主题 msg['To']=','.join(toemails) #收件人 msg['From']=frommail #发送人 #STMP stmp=smtplib.SMTP(stmpserver163,stmpport) #创建STMP stmp.login(frommail,code163) # 发送邮件,发送人,收邮件人,发送内容 stmp.sendmail(frommail,toemails,msg.as_string()) stmp.close() print("email ok") except Exception as ex: print(ex)
标签:python,stmp,发送,emailhelper,frommail,msg,com,邮件 From: https://www.cnblogs.com/geovindu/p/17574734.html