5

We use Mailgun to send out emails and recently I noticed quite a few emails each day are being rejected by Gmail.

Here's the type of message we receive:

550
5.7.1 [184.173.153.6      11] Our system has detected that this message is
5.7.1 not RFC 2822 compliant. To reduce the amount of spam sent to Gmail,  
5.7.1 this message has been blocked. Please review
5.7.1 RFC 2822 specifications for more information. f15si23385851vdu.1 - gsmtp

The RFC 2822 spec is a massive document so I haven't read it front-to-back but from looking at resources around the web our emails don't fall into any of the common pitfalls that would trigger this type of response from Gmail.

Here's an example email header:

Received: by luna.mailgun.net with HTTP; Mon, 29 Jun 2015 21:06:59 +0000
Message-Id: <20150629210659.18668.39318@(domain)>
X-Mailgun-Variables: {"variation": "original", "campaign_code":
 "(customValue)"}
Reply-To: (name) <(email)>
X-Mailgun-Track: false
X-Mailgun-Tag: (customTag)
To: (email)
From: (name) <(email)>
Subject: (subject)
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="12f0bd630f2145a3afcd98b621a3b1f2"

--12f0bd630f2145a3afcd98b621a3b1f2
Content-Type: text/plain; charset="ascii"
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit

(text content)

--12f0bd630f2145a3afcd98b621a3b1f2
Content-Type: text/html; charset="ascii"
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>(title)</title>
<style type="text/css">
(css)
</style>

</head><body style="(css)" >
  (content)
</body>
</html>
--12f0bd630f2145a3afcd98b621a3b1f2--

What are we doing wrong?

Desmond Weindorf
  • 268
  • 3
  • 11
  • Have you asked mailgun support out of interest? I suspect they have the best expertise to answer your question. I'd assume that in general mailgun don't send out invalid emailis though so it must be a setting you have set that is causing the problem. One thing I wonder about is the charset. Your mime content type charset disagrees with the html's meta charset. Not sure if this would generate this error though. – Chris Jul 01 '15 at 15:18
  • We're also using Mailgun and also seeing an increased number of RFC 2822 rejections. It seems to be random. Sending one email to 10 recipients, we might get a failure with one, then the next email to that same set of recipients will succeed, then another will fail for a different recipient in the set. After going back and forth on it with Mailgun support their suggestion was for us to contact Google. – kshep Jul 02 '15 at 22:04
  • Is this still occurring for you between Mailgun and Gmail? I've seen the same random error on different recipients half a dozen times over the last month using Mailgun and Gmail, not before that. – Jonathon Rossi Sep 22 '15 at 02:45

2 Answers2

2

One obvious rfc2822 violation in your example is the missing Date header .

from rfc2822, Section 3.6:

The only required header fields are the origination date field and
the originator address field(s).

Community
  • 1
  • 1
Gryphius
  • 75,626
  • 6
  • 48
  • 54
2

It turned out we were using two different domains for the From and Reply-to which I guess is a no-no.

Desmond Weindorf
  • 268
  • 3
  • 11