使用python脚本发送电子邮件(来自mydomain.com)与使用webmail不同?

时间:2017-10-19 09:42:03

标签: python smtplib

我有一个个人域名(让我们称之为domain.com),使用公开签名的证书来发送和接收电子邮件。我使用iRedMail webmail,我可以发送电子邮件到几乎任何其他域名,包括gmail.com和ymail.com,没有任何问题。 现在我想在同一个电子邮件服务器框中使用本地python脚本发送电子邮件。这是我的代码的一部分:

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"

这是来自/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))

我在这里缺少什么?为什么这是一种不同的行为?

0 个答案:

没有答案