2

I got an error mail message :  

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

I stuck with this for a while I don't know where ia wrong
I try smtplib.SMTP('smtp.gmail.com',587) works well
But company smtp fail
I think this line is weild :

 Received: from  localhost.localdomain (unknown [192.X.X.X])  

Do you have any ideas?
Please help me Thank you

Here is code :

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()
user2492364
  • 6,543
  • 22
  • 77
  • 147

1 Answers1

2

Your sender address (from field in the email) must be a existing email address on the mailsever you use (mail.stmpcompany.tw).

The error message

5.7.1 This system is configured to reject spoofed sender addresses

occurs when you use an email address in the from field that either does not belong to a domain which the mailserver is configured for or the server also requries that a user with that emailaddress actually exists.

Your test with gmail worked because googles mailserver doesn't check whether the senders address is valid or not.

Sebastian Stigler
  • 6,819
  • 2
  • 29
  • 31
  • I think You are right.I really use ````from@mysite.com```` from ````http://stackoverflow.com/questions/540976/specify-a-sender-when-sending-mail-with-python-smtplib?rq=1```` And It works !!! it's weird to use ````from@mysite.com```` sounds like a fake sender.But it really works. – user2492364 Oct 02 '15 at 16:27