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()
时间: 2024-10-17 14:25:00