[Solved] smtplib Sent Email Error: SMTPDataError: (554, ‘DT:SPM 163 smtp1

When I send mail! The authorization code is written correctly in all aspects! But I encountered the following exception!

raise SMTPDataError(code, resp)
SMTPDataError: (554, 'DT:SPM 163 smtp14,EsCowABXOeQy9p5hou3fMw--.131S2 1637807667,please see http://mail.163.com/help/help_spam_16.htm?ip=')

At first, I thought there was a problem with the content of the transmitted text! It is regarded as spam and cannot be sent! Then I changed it many times! Then I looked for it for a long time! Just found that it was from and to’s pit!

Questionable code:
import smtplib
from email.mime.text import MIMEText
from email.header import Header

sender = '******@163.com'
receivers = ['******@qq.com','******@163.com']
body_content = """ TEST TEXTS """

message = MIMEText(body_content, 'plain', 'utf-8')
message['From'] = "********@163.com"
message['To'] = "******@qq.com"
subject = """

Replace with:

message['Subject'] = Header(subject, 'utf-8')
smtpObj = smtplib.SMTP()
smtpObj.connect(mail_host, 25)
smtpObj.sendmail(sender, receivers, message.as_string())
print("Mail sent successfully")
Here the message['From'] and To are changed to the From and To character format of the emails sent and received in the mailbox!

message['From'] = "wumian<**********@163.com>"
message['To'] = "qishi<**********@qq.com>"


Similar Posts: