I have a personal domain name (let's call it domain.com) that uses publicly signed a certificate to send and receive emails. I use iRedMail webmail, and I can send emails to almost any other domain names including gmail.com and ymail.com with no issue. Now I would want to send email using python script locally from the same email server box. here is a part of my code:
msg = MIMEMultipart('related')
msg['Subject'] = "Welcome to my website"
msg['from'] = "activity@mydomain.com"
part = MIMEText("Body of the email",'plain')
msg.attach(part)
fromaddr = "activity@mydomain.com"
toaddrs = "someone@gmail.com"
username = "activity@mydomain.com"
password = "password"
# The actual mail send
try:
server = smtplib.SMTP('mydomain.com',587)
server.starttls()
server.login(username,password)
#server.ehlo()
server.sendmail(fromaddr, toaddrs, msg.as_string() )
server.quit()
except:
print "Error: unable to send email"
and here is the log from /var/log/mail.log:
Oct 19 22:11:52 box postfix/smtp[28666]: Untrusted TLS connection established to alt1.gmail-smtp-in.l.google.com[74.125.198.26]:25: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Oct 19 22:11:52 box postfix/smtp[28666]: B3F0F10583D: to=<someone@gmail.com>, relay=alt1.gmail-smtp-in.l.google.com[74.125.198.26]:25, delay=602, delays=598/0.01/4/0.5, dsn=4.7.0, status=deferred (host alt1.gmail-smtp-in.l.google.com[74.125.198.26] said: 421-4.7.0 [202.89.139.221 15] Our system has detected that this message is 421-4.7.0 suspicious due to the very low reputation of the sending IP address. 421-4.7.0 To protect our users from spam, mail sent from your IP address has 421-4.7.0 been temporarily rate limited. Please visit 421 4.7.0 https://support.google.com/mail/answer/188131 for more information. t16si4047297oih.239 - gsmtp (in reply to end of DATA command))
What am I missing here? Why is this a different behaviour?