python-python发送邮件
代码:
import smtplib
from email.mime.text import MIMEText
msg_from = "275712541@qq.com" # 填入发送方邮箱
pwd = "cpazwmwjtbvobigd" # 填入发送方邮箱smtp授权码
to = "13260676190@163.com" # 填入发送方邮箱
subject = "这是python发送的" # 电子邮件的主题
content = "hello world" # 电子邮件的内容
# 构造邮件(注意大写字母)
msg = MIMEText(content)
msg["Subject"] = subject
msg["From"] = msg_from
msg["To"] = to
# 发送邮件
try:
ss = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发送方邮箱smtp安全协议
ss.login(msg_from, pwd) # 登录
ss.sendmail(msg_from, to, msg.as_string()) # 发送
print("发送成功")
except Exception as e:
print("发送失败:", e)

浙公网安备 33010602011771号