from email.mime.text import MIMEText import smtplib import getpass msg = MIMEText('这是一封来自python的纯文本邮件','plain','utf-8') from_addr = '发件人邮箱地址' password = getpass.getpass('Password:') smtp_server = 'smtp.163.com' smtp_port = 994 to_addr = '收件人邮箱地址*' server = smtplib.SMTP(smtp_server,smtp_port) server.starttls() server.set_debuglevel(1) server.login(from_addr,password) server.sendmail(from_addr,[to_addr],msg.as_string()) server.quit()
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8229.html