Python:脚本发送的邮件被Gmail标记为垃圾邮件

时间:2012-05-04 08:42:02

标签: python email gmail spam

我们有一个python脚本,每天将邮件发送到xml地址列表。这些邮件始终被Gmail标记为垃圾邮件。这是代码:

            email_body =  '<html><body><div style="text-align: center; font-family: serif; font-size: 15px;"><br/><br/>@<br/><br/>' + text_splited[i] + '<br/><br/>@<br/><br/><a href="http://anemailstory.net/"><i>Tr@ces</i></a><br/><br/> - <br/><br/><a href="http://anemailstory.net/unsubscribe.html">unsubscribe</a><br/><br/></div></body></html>'  
#text corresponding to that subcription date    

            # email     
            msg = MIMEMultipart('alternative') #Create Multipart msg (allows html)
            msg['To'] = email.utils.formataddr(('Recipient', 'readers@traces.net'))
            msg['From'] = email.utils.formataddr(('Traces', 'traces@anemailstory.net'))
            msg['Subject'] = 'Tr@ces - Part #' + str((i+2))

            part_html = MIMEText(email_body, 'html')
            msg.attach(part_html)

            server = smtplib.SMTP('localhost')
            server.set_debuglevel(False) # show communication with the server
            try:
                server.sendmail('traces@noreply.net', email_addrs, msg.as_string())
            finally:
                server.quit()

这是生成的电子邮件:

Return-path: <traces@noreply.net>
Envelope-to: mimmo@mimmo.com
Delivery-date: Wed, 25 Apr 2012 23:59:07 -0600
Received: from localhost ([127.0.0.1] helo=host131.hostmonster.com)
    by host131.hostmonster.com with esmtp (Exim 4.76)
    (envelope-from <traces@noreply.net>)
    id 1SNHjO-0006T0-C2; Wed, 25 Apr 2012 23:59:06 -0600
Content-Type: multipart/alternative;
    boundary="===============1468314745133566460=="
MIME-Version: 1.0
To: Recipient <readers@traces.net>
From: Traces <traces@anemailstory.net>
Subject: Tr@ces - Part #9
X-Identified-User: {:host131.hostmonster.com:andrecas:host131.hostmonster.com} {sentby:program running on server}

--===============1468314745133566460==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

<html><body><div style="text-align: center; font-family: serif; font-size: 15px;"><br/><br/>@<br/><br/><br/>Mail content<br/><br/><br/>@<br/><br/><a href="http://anemailstory.net/"><i>Tr@ces</i></a><br/><br/> - <br/><br/><a href="http://anemailstory.net/unsubscribe.html">unsubscribe</a><br/><br/></div></body></html>
--===============1468314745133566460==--

你有解决方法吗?

感谢。

4 个答案:

答案 0 :(得分:6)

您的电子邮件几乎只包含HTML和链接。闻起来像垃圾邮件。

建议:

  • 发送纯文本电子邮件(不太可能被视为垃圾邮件 - 对许多用户来说更为舒适)
  • 如果您使用HTML,请始终包含纯文本版本
  • 改善文字到链接/ HTML比率。

答案 1 :(得分:2)

嗯......取决于SMTP的签名,可能接近“垃圾邮件”。

  1. 尝试将“noreply.net”更改为真实域名

  2. 也可能是服务器主机名* .hostmonster.com在垃圾邮件列表中,因为来自任何服务器的已知垃圾邮件(经常发生)

  3. 许多其他原因......

    • 错误的新行
    • 错误的日期/时间格式
    • 电子邮件客户端无法处理您的邮件(格式错误)
  4. 尝试使用其他SMTP服务器,查看它是签名还是服务器,而不是您的脚本!

  5. 还尝试使用较少的图片/链接发送邮件,甚至发送更多文字!

  6. 如果是垃圾邮件,请提供一些有关X-Spam-Status,X-Spam-Level,X-Spam-DCC(Header elements)的信息。他们提供了关于出错的最佳概述!

    - 有关垃圾邮件的一些其他信息:http://emailium.com/blog/wp-content/uploads/2011/02/Exact-Target-Infographic-Spam_vs_Whitelist-v2.jpg

答案 2 :(得分:0)

另请尝试Google提供的此帮助文档。如果您相应地执行了所有操作,则可以与Google支持小组联系。

https://support.google.com/mail/bin/answer.py?hl=en&answer=81126

答案 3 :(得分:0)

如果您使用 google smtp 发送电子邮件,请确保使用与您的名字匹配的发件人姓名和与您的 google 帐户匹配的姓氏,例如:

名字:约翰 姓氏:Doe

在蟒蛇中:

sender_address = john.doe@gmail.com

message["From"] = f"John Doe{sender_address}"

这让我犯了很多错误和尝试。