Python: Mail sent by script marked as Gmail spam

We have a python script that sends emails to the xml address list daily. These emails are always marked as Gmail spam. Here is the code:

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() 

And here is the generated email:

 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==-- 

Do you have a solution for this?

Thanks.

+3
source share
3 answers

Your email address is almost HTML and a link. It smells of spam.

Suggestions:

  • Send a clear text message (less likely to be considered spam - and more convenient for many users).
  • If you use HTML, always include the plaintext version.
  • Improved text-to-links / html ratio.
+5
source

Hum ... depends on the SMTP signature, which may be close to spam.

  • try changing "noreply.net" to a real domain

  • Perhaps the server name of the * .hostmonster.com server is in the spam list due to known spam from any of their servers (often).

  • Many other reasons ...

    • wrong new lines
    • wrong date / time format
    • Email client cannot process your mail (wrong format)
  • Try using a different SMTP server to make sure it is a signature or server, not your script!

  • Also try sending Mails with fewer images / links and even a lot more text!

If this is spam, could you provide some information about X-Spam-Status, X-Spam-Level, X-Spam-DCC (Header Elements). They give a better overview of what is going wrong!

- Additional information about spam: http://emailium.com/blog/wp-content/uploads/2011/02/Exact-Target-Infographic-Spam_vs_Whitelist-v2.jpg

+1
source

Also try this help document from Google. If you did everything right, you can contact Google support.

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

0
source

Source: https://habr.com/ru/post/973616/


All Articles