python 发送邮件给单个人, 需要修改以下三个地方(好久之前写过的代码,做个记录)。
_user = "xx@qq.com" //QQ邮箱
_pwd = "授权码" //QQ的授权码
_to = "yy@163.com" //163邮箱 或其他邮箱
#!/usr/bin/env python # -*-coding:utf-8-*- import smtplib from email.mime.text import MIMEText _user = "xx@qq.com" //QQ邮箱 _pwd = "授权码" //授权码 _to = "yy@163.com" //163邮箱 msg = MIMEText("Test") msg["Subject"] = " don't panic" msg["From"] = _user msg["To"] = _to try: s=smtplib.SMTP_SSL("smtp.qq.com",465) s.login(_user,_pwd) s.sendmail(_user,_to,msg.as_string()) s.quit() print("Success!") except smtplib.SMTPException as e: print("Failed,%s"%e)