Sending HTML to Gmail always lands in Spam

5,873

Solution 1

Make sure your SMTP server is not configured as an open relay (test)

It's possible that Gmail will flag an email as SPAM if it matches an email previously flagged as SPAM. So it's possible that if you're sending to the same Gmail account, your changes haven't made a difference if the original email from that sender was already flagged as SPAM (since it's been 'flagged' by Gmail already). Check any previous messages, and try clicking "Not SPAM". Better yet, try sending to multiple Gmail accounts.

Other potential problems areas to test might include:

  1. Ensure the sender address matches the domain that the links are pointing to.
  2. Try reducing the number of links in the email
  3. Try removing the link target attributes (which might be unnecessary anyway)
  4. The CAN-SPAM act makes it illegal to distribute emails without clear unsubscribe options.
  5. The CAN-SPAM act requires a physical mailing address for the sender (I believe it's still considered within legal realm to use a PO Box, but some servers might regard this as another flag)

Solution 2

If you are generating the email in php, remember to add return-path to your headers. Other details like clean code and light message are already in the thread.

Of course you are setting the from header, right?

Other tips are:

  • set reply-to
  • use \r\n as line ending with no spaces around

Have you tried to send the mail to different accounts? like hotmail, yahoo, you isp's service, etc. That way you are sure that the problem is your message and not the receiver server rules.

Bye

Share:
5,873

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I am having an issue with sending HTML emails to Gmail. I can send them to Yahoo, Hotmail, RR, AOL, etc. with no problem at all, but when I send them to Gmail I get kicked to spam.

    I have checked my IP with a lot of different list to make sure it is not listed anywhere, which it is not.

    spamhaus =  is not listed in the DBL
    abuse.net = is not listed in the SBL
    abuse.net = is not listed in the PBL
    abuse.net = is not listed in the XBL
    spamcop = not listed in bl.spamcop.net
    
    host 24.172.204.xxx
    xxx.204.172.24.in-addr.arpa domain name pointer xxxevents.com.
    
    
    host xxxevents.com
    xxxevents.com has address 24.172.204.xxx
    xxxevents.com mail is handled by 10 mail.xxxevents.com.
    

    I am just trying to send a very VERY basic HTML message (listed below). I use an Ubuntu server, swiftmailer, multipart/alternative (HTML & plain), SPF = pass, and I am going to setup DKIM today to see if that fixes it (but I doubt it will)...

    For now I will only post the message I sent that gets kicked to spam and can provide any details needed.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>Triathlon</title></head>
    <body>
    <table cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <p>Thank you for attending our 4th annual Triathlon/Duathlon/5k at Hueston Woods State Park on August 12th.
    This event is held annually to raise research funding for Crohn's Disease, Ulcerative Colitis, and Muscular Dystrophy diseases.</p>
    </td>
    </tr>
    <tr>
    <td>
                            <p>As you know the results and pictures have been posted on our home page at  since Sunday 8/13/2012. Now we also have updated our Facebook page with those photos and you can start tagging yourself or downloading the pictures now!
                            <br />
                            our page and tag yourself at
                            </p>
                            <p>
                            test test
                            </p>
                            <p>Race day events is professionally managed by Speedy-Feet</p>
    
    </td>
    </tr>
    </table>
    </body>
    </html>
    

    Just plain text works great, I thought maybe wording was messing me up but not the case... I am almost done install opendkim so I will be able to rule that out very soon.

    Edit:

    Okay installed opendkim and I am getting passing results so I sent the html I posted above it went through just fine. So now when I start to add a few more lines I am getting kicked back to spam again. Here is updated html code:

     `   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>Triathlon</title></head>
    <body>
    <table cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <center><a href='http://xxxevents.com' target="_blank">
                    <font face="Verdana, Arial, Helvetica, sans-serif" color="#666666" size="2">
                    <img src="http://xxxevents.com/marketemailimages/xxxlogo.png" alt="xxx It Events | Raising funds for Crohns, Colitis, and Muscular Dystrophy" border="0" />
                    </font></a></center>
    </td>
    </tr>
    <tr>
    <td>
    <p>Thank you for attending our 4th annual Triathlon/Duathlon/5k at Hueston Woods State Park on August 12th.
    This event is held annually to raise research funding for Crohn's Disease, Ulcerative Colitis, and Muscular Dystrophy diseases.</p>
    </td>
    </tr>
    <tr>
    <td>
                            <p>As you know the results and pictures have been posted on our home page at  since Sunday 8/13/2012. Now we also have updated our Facebook page with those photos and you can start tagging yourself or downloading the pictures now!
                            <br />
                            our page and tag yourself at
                            </p>
                            <p>
                            test test
                            </p>
                            <p>Race day events is professionally managed by Speedy-Feet</p>
    
    </td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td valign="top">
    <div align="center" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;"><br />PO Box xxx
    Maineville, OH 45039<br />
    <a href="mailto:[email protected]">[email protected]</a> | <a href='http://xxxevents.com' target="_blank">xxxevents.com</a><br />
    <br />  
    </div>
    </td>
    </tr>
    </table>
    
    </body>
    </html>`
    

    EDIT:

    Thank you for your response Andrew, unfortunately that did not fix my issue.... I tried sending the exact message above (not containing any spam) and its still being caught. I am at wits end with gmail. Although I seriously doubt it is a system setting that is throwing me off, I am more than happy to email any information you may need to help me though this... As stated before my ip is clear, html validates with W3, removed all usage of spammy verbiage, and stripped out anything that I can think of that would cause it go to spam, send it and wham spam....

    EDIT:

    Thank you for your response Nick, Yes xxx was simply to mask it, although I am starting to think I will not get resolution this way. If you think it will help let me know and I will just post the real html and we can see if we can get this thing going.

    EDIT:

    Thank you for your response Gabriel, I double checked my ip and got the follow results;

        Test    Result
    SMTP Reverse Dns    OK - 24.172.204.xxx resolves to xxxevents.com
    SMTP Reverse DNS Mismatch   OK - Reverse DNS matches SMTP Banner
    SMTP TLS    OK - Supports TLS.
    SMTP Connection Time    0 seconds - Good on Connection time
    SMTP Open Relay     OK - Not an open relay.
    SMTP Transaction Time   0.593 seconds - Good on Transaction Time
    

    Okay lets try it like this, this is the original message (quoted-printable) sent. xxx is just add for posting purposes. So if I send

    ` Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

    Thank you for attending our 4th annual Triathlon/= Duathlon/5k at Hueston Woods State Park on August 12th. This event is= held annually to raise research funding for Crohn's Disease, Ulcerative= Colitis, and Muscular Dystrophy diseases. As you know the r= esults and pictures have been posted on our home page at since Sunday 8= /13/2012. Now we also have updated our Facebook page with those photos a= nd you can start tagging yourself or downloading the pictures now! o= ur page and tag yourself at test test Race day events is profess= ionally managed by Speedy-Feet PO Box xxx Maineville, OH xxx39<= table cellspacing=3D'0' cellpadding=3D'0'>This email was sent to [email protected] if you would like to = be removed click here http://xxxevents.com/removeme.php?rem= [email protected]' > http://xxxevents.com/removeme.php?re= [email protected]`

    It goes through just fine, no issues at all. However if I send this;

    ` Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

    Thank you= for attending our 4th annual Triathlon/Duathlon/5k at Hueston Woods Sta= te Park on August 12th. This event is held annually to raise research fu= nding for Crohn's Disease, Ulcerative Colitis, and Muscular Dystrophy di= seases.


    As you know the results and pictures have been po= sted on our home page at since Sunday 8/13/2012. Now we also have updat= ed our Facebook page with those photos and you can start tagging yoursel= f or downloading the pictures now! our page and tag yourself at <= hr /> Race day events is professionally managed by Speedy-Feet P= O Box xxx Maineville, OH xxx39 This email was sent to [email protected] if you would like to be re= moved click here http://xxxevents.com/removeme.php?remo= [email protected]' > http://xxxevents.com/removeme.php?rem= [email protected]

    `

    Then it goes straight to spam.... Its the exact same message the only difference are the tables, the links everything is exactly the same.... I just dont understand.

    • Admin
      Admin over 11 years
      Writing valid HTML may help. (Use the "Code" button when pasting HTML code to the question.)
    • Admin
      Admin over 11 years
      Just to clarify: If you send plaintext it works?
    • Admin
      Admin over 11 years
      Is the xxxevents.com URL in your HTML code part of the email you're sending, or have you just masked the actual address using xxx? If it does contain that URL, there's a good chance that your email is being flagged as spam because 'xxx' is likely to be blacklisted.
    • Admin
      Admin over 11 years
      Another thing to check: make sure that the plain text part of your email is very similar to the HTML part (minus the tags, of course). If you've added content to the HTML part that's not in the text part, some spam filters will flag it. If that doesn't work, I would suggest removing code from the second <table> one portion at a time and resending until you find out what it is that's hitting the filter.
    • Admin
      Admin over 11 years
      If you have unsubscribe option, maybe you should add unsubscribe link in footer.