all guides

// how to fix

Gmail "550-5.7.1 ... is not RFC 5322 compliant": fix missing or duplicate headers

Gmail rejected your email because its headers break the RFC 5322 standard: missing or duplicate From, Date or Message-ID. Here is how to fix it.

What it means

Every email has a header section with fields such as From, To, Date, Subject and Message-ID. RFC 5322 is the standard that says how these headers must be written. Gmail rejects emails that break basic rules. The bounce usually looks like this:

550-5.7.1 [203.0.113.10] Our system has detected that this message is not
550-5.7.1 RFC 5322 compliant:
550-5.7.1 'From' header is missing.
550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been
550-5.7.1 blocked. Please visit
550-5.7.1  https://support.google.com/mail/?p=RfcMessageNonCompliant
550 5.7.1 and review RFC 5322 specifications for more information.

The line in the middle tells you what is wrong, for example Multiple 'From' headers found or a missing or invalid header. Read it carefully: it is the key to the fix.

Why it happens

This error almost always comes from an application, script or plugin that builds emails itself, rather than from a normal mail program:

  • No From header, or a From with an invalid address (spaces, missing domain, wrong quotes around the display name).
  • Duplicate headers: two From, two Subject, two To or two Date lines, often because the code adds a header that the mail library already adds.
  • Missing Date or Message-ID, or a Date in a wrong format.
  • Badly formed headers: lines that are not encoded properly, non-ASCII characters in a header without encoding, or a broken line break that merges the headers into the body.

How to check

  • Send a test email: on the Delivmail home page (/), copy your unique test address and send it a normal email from the same server, tool or mailbox that bounced. Open the report when it is ready.
  • Look at the headers in the report, or view the original source of the email (in Gmail, "Show original"). Check that there is exactly one From, one Date, one Subject and one Message-ID.
  • Look at the sending code. Search for places where headers are added by hand, such as From: strings concatenated in PHP mail() calls.

How to fix it

  1. Use a proper mail library (PHPMailer, Nodemailer, the email module of your framework) instead of building headers as text. These libraries add Date and Message-ID and encode headers correctly.
  2. Set exactly one From address with a valid format, for example:
    From: Your Shop <orders@yourdomain.com>
    Put quotes around display names that contain commas or special characters.
  3. Remove duplicate headers. If the library sets From or Subject, do not add them again in a custom header list.
  4. Add a Date and a Message-ID if your system does not. A Message-ID looks like <unique-id@yourdomain.com>.
  5. Encode non-English characters in Subject and names using your library's built-in encoding.
  6. Use the correct line endings (CRLF) between headers, and one empty line between headers and body.
  7. Update plugins (WordPress form or SMTP plugins, shop extensions): old versions often cause these errors.

Check that it is fixed

Send a new email from the same application to a new Delivmail test address and review the headers in the report. When they are correct, send the email again to the Gmail address that bounced. There is no reputation delay for this error: once the headers are valid, Gmail stops rejecting for this reason.

Check that it is fixed

DNS changes can take from a few minutes to a few hours. Then send a new test email or scan your domain again.

Related guides