import smtplib from email.mime.text import MIMEText from email.utils import formataddr msg = MIMEText("你好", 'html', 'utf-8') msg['From'] = formataddr(["鲍佳会", "bjh123der@126.com"]) #发送方 msg['Subjext'] = "Python代码发送邮件测试" #主题 server = smtplib.SMTP_SSL("smtp.126.com") server.login("bjh123der@126.com", "OOUGOHMXIXCHIKCW") #登录 server.sendmail("bjh123der@126.com", "1442247835@qq.com", msg.as_string()) #发送 server.quit()
运行报错:
D:\PYTHON\python.exe D:/邮件/main.py
Traceback (most recent call last):
File "D:\邮件\main.py", line 15, in <module>
server.sendmail("bjh123der@126.com", "1442247835@qq.com", msg.as_string()) #发送
File "D:\PYTHON\lib\smtplib.py", line 908, in sendmail
raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp1,C8mowADHo3DL0QhjXZFrAA--.46904S2 1661522379,please see http://mail.163.com/help/help_spam_16.htm?ip=59.62.93.209&hostid=smtp1&time=1661522379')