我试图用下面的amazon SES API文档发送电子邮件,python返回代码250,表示可以,但我的电子邮件收到了一条失败消息。有人能告诉我可能出了什么问题吗?谢谢
python:
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# https://us-east-2.console.aws.amazon.com/sesv2/home?region=us-east-2#/account
# https://console.aws.amazon.com/iam/home?#/s=SESHomeV4/us-east-2
mail_host = "email-smtp.us-east-2.amazonaws.com"
mail_user = "AKI....T7H"
mail_pass = "BHJ.....iS/x"
sender = 'thelou1s@...com'
receivers = 'thelou1s@...com'
msg = MIMEMultipart()
msg['From'] = sender
msg['To'] = receivers
msg['Subject'] = 'simple email in python'
message = 'here is the email'
msg.attach(MIMEText(message))
try:
print("try smtplib.SMTP")
smtp = smtplib.SMTP(mail_host, 587)
smtp.set_debuglevel(True)
print("try connect")
smtp.ehlo()
smtp.starttls()
smtp.ehlo()
# smtpObj.connect(mail_host, 465)
print("try login")
smtp.login(mail_user, mail_pass)
print("try sendmail: " + msg.as_string())
smtp.sendmail(sender, receivers, msg.as_string())
print("Send Success")
smtp.close()
except smtplib.SMTPException:
print("Send Error")
log(retcode 250是否意味着在代码端或用户端成功?(:
reply: retcode (250); Msg: b'Ok 010f017d8f0f1703-d018f2a9-833e-428e-9010-5e45818e51e4-000000'
data: (250, b'Ok 010f017d8f0f1703-d018f2a9-833e-428e-9010-5e45818e51e4-000000')
Send Success
来自亚马逊的电子邮件:
Delivery Status Notification (Failure)
An error occurred while trying to deliver the mail to the following recipients:
thelou1s@...com
here is the email
只需在亚马逊控制台中验证您的电子邮件