我收到了错误邮件:
User_One@mycompany.com
Your message wasn't delivered due to a permission or security issue.
It may have been rejected by a moderator, the address may only accept e-mail
from certain senders, or another restriction may be preventing delivery.
smtp; 550 5.7.1 This system is configured to reject spoofed sender addresses> #SMTP#
Original message headers:
Return-Path: <User_One@mycompany.com>
Received: from localhost.localdomain (unknown [192.X.X.X]) (using
TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client
certificate requested) by smtpcompany.tw (Postfix) with ESMTPS id CB8752E03B7 for
<User_One@mycompany.com>; Fri, 2 Oct 2015 14:24:41 +0800 (CST)
Content-Type: multipart/mixed; boundary="===============1672092220=="
MIME-Version: 1.0
From: <User_One@mycompany.com>
To: <User_One@mycompany.com>
Subject: We got something
我坚持了一段时间
我不知道哪里错了
我尝试smtplib.SMTP('smtp.gmail.com',587)
效果很好
但公司smtp失败了
我认为这一行是非常的:
Received: from localhost.localdomain (unknown [192.X.X.X])
你有什么想法吗? 请帮帮我谢谢
这是代码:
def send_email(mail_from,mail_to,subject, body):
import smtplib
from email.mime.multipart import MIMEMultipart
fromaddr = mail_from
toaddr = mail_to if type(mail_to) is list else [mail_to]
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = ", ".join(toaddr)
msg['Subject'] = subject
body = body
server = smtplib.SMTP('mail.stmpcompany.tw', 25)
server.set_debuglevel(True)
server.starttls()
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()
答案 0 :(得分:0)
您的发件人地址(来自电子邮件中的字段)必须是您使用的邮件服务器上的现有电子邮件地址(mail.stmpcompany.tw)。
错误消息
当您在from字段中使用不属于为其配置邮件服务器的域的电子邮件地址或服务器也要求具有该电子邮件地址的用户实际存在时,会发生5.7.1此系统配置为拒绝欺骗性发件人地址
。
你的gmail测试有效,因为googles mailserver不会检查发件人地址是否有效。