Some links on this page are affiliate links. If you sign up through one, Rigcheck may earn a commission at no cost to you. It doesn't change what this guide recommends. How we handle this.
Your email to a Gmail or Google Workspace address bounced with this:
550 5.7.1 Messages missing a valid Message-ID: header are not accepted.Gmail checks that every message has a Message-ID, a unique label in its headers, and that the label is written correctly. Google's own sender guidelines say to make sure every message includes a valid Message-ID. Mail from people using ordinary email programs always has one, so this bounce almost always comes from an app, a script or a device that builds its own messages.
The fix is in whatever sent the message, not in your DNS records. This guide shows how to find it and add the header.
What a Message-ID looks like
It's one line in the message headers, which you don't normally see:
Message-ID: <20261120093015.4f2a9c1e@mail.yourdomain.com>The rules come from RFC 5322, the standard for the format of email messages:
- Angle brackets around the whole value:
<at the start and>at the end. - Two parts joined by an
@: something unique on the left, usually a domain name on the right. - No spaces inside the brackets.
- Unique to each message, and only one
Message-IDline per message.
The standard says a message should have one rather than must, which is why some mail servers accept messages without it. Gmail doesn't.
The error says "missing", but a Message-ID that's there and badly written gets the same bounce. A value without angle brackets, with a space in it, or without an @ counts as missing.
Step 1: Find what sent the message
Look at the bounce and the message it returned. Which system sends mail like that? The usual suspects:
- Your own code: a contact form, sign-up confirmation or report that builds the message itself, especially code that talks to an SMTP server directly.
- An app or plugin with a "custom headers" setting, where a header set by hand replaced the one the library would have added.
- A device: a scanner, printer, alarm panel or NAS that sends notifications.
- A mail server or relay you run, passing on messages from any of the above without adding the header.
Step 2: See what it actually sends
Gmail rejected the message, so you can't open it there. Send the same kind of message to a mailbox that accepts it, then view its headers:
- Outlook on the web: open the message, select the three dots, then View → View message source.
- A test inbox such as Mailtrap's Email Sandbox, which catches messages from your app and shows their headers. Setting up the Mailtrap Email Sandbox shows how to point an app at it.
Search the headers for Message-ID. If there's no such line, the sender isn't adding one. If there is, compare it with the rules above.
Step 3: Add the header
Most email libraries add a correct Message-ID on their own. The bounce usually means the message was built without one, or the library's value was overwritten.
Python
Python's email package doesn't add a Message-ID for you when you build a message and send it with smtplib. Add one with make_msgid, using your own domain:
from email.message import EmailMessage
from email.utils import make_msgid, formatdate
msg = EmailMessage()
msg["From"] = "alerts@yourdomain.com"
msg["To"] = "someone@gmail.com"
msg["Subject"] = "Your report is ready"
msg["Date"] = formatdate(localtime=True)
msg["Message-ID"] = make_msgid(domain="yourdomain.com")
msg.set_content("...")Frameworks such as Django add one for you.
Node.js
Nodemailer adds a Message-ID automatically. If you set messageId yourself, or a Message-ID entry under headers, check that it has the angle brackets and an @. Removing your own value and letting Nodemailer create one is the simplest fix.
PHP
PHPMailer adds one automatically. PHP's built-in mail() hands the message to the server's mail program, which usually adds one; if bounces still mention the Message-ID, add the header yourself or switch to a library.
A mail server or relay you run
A server that relays messages for apps and devices can add the header when it's missing. In Postfix, that's the always_add_missing_headers setting. Other servers have their own option; check their documentation for "missing headers" or "Message-ID".
A device or hosted service
You can't change how a scanner or a hosted app builds its messages. Look for a firmware or software update, ask the vendor, or send its mail through a relay that adds missing headers.
Step 4: Resend and check
- Send a new message the same way as the one that bounced. Gmail doesn't retry a rejected message, so anything that bounced has to be sent again.
- In Gmail, open the message, select the three dots and choose Show original. You should see a
Message-IDline, and PASS next to SPF, DKIM and DMARC. - If SPF, DKIM or DMARC don't pass, paste the headers into the email header analyzer to see which domain each check used.
Other Gmail 5.7.1 header bounces
Gmail rejects other badly formed headers with similar messages. These are from Google's list of SMTP errors, as of November 2026:
| The bounce says | What to fix |
|---|---|
| Messages missing a valid address in the From: header, or having no From: header, are not accepted. | Add a From line with one valid address. |
| Messages with multiple addresses in the From: header are not accepted. | Put one address in From. Use Reply-To for others. |
| This message is not RFC 5322 compliant because it has duplicate headers. | A header such as Subject, Date or Message-ID appears twice. Keep one. |
| 421 4.7.28 … the same Message-ID | The Message-ID repeats across messages. Make it unique. |