What are common formatting pitfalls in email headers?

Still have a question, spotted an error, or have a better explanation or a source we should cite?

Email headers are where things like "From:", "To:", and "Subject:" live. They're formatted in a very specific way (defined by RFC 5322, the internet standard for email structure), and even tiny mistakes can cause receiving servers to reject your messages or flag them as spam.

The most common mistakes:

  • Missing the colon. Every header field needs one. "From sender@example.com" won't work. It needs to be "From: sender@example.com".
  • Wrong line breaks. Headers must end with a carriage return AND a line feed (written as \r\n in code). If your system only uses line feeds (\n), some mail servers will reject the entire message. This happens more often than you'd think when developers hand-code SMTP.
  • Extra spaces. A space before the colon, or random spaces inside field names, breaks parsing. "From : sender@example.com" is invalid. So is "Fr om: sender@example.com".
  • Unquoted or badly quoted values. If a display name has special characters (commas, quotes, parentheses), it needs to be properly quoted. "From: John Doe, Jr. <john@example.com>" will confuse parsers. It should be "From: \"John Doe, Jr.\" <john@example.com>".
  • Duplicate fields that shouldn't be duplicated. You can have multiple "Received:" headers (mail servers add them as the message travels), but you can't have two "From:" headers or two "Subject:" headers. Servers will reject that.
  • Headers that are too long. Each header line should be 78 characters or less. If you need more, you fold the line by starting the next line with a space or tab. Not doing this can cause truncation or rejection.

If you're using an ESP like Mailchimp, SendGrid, or Postmark, they handle header formatting for you. You won't run into these issues unless you're adding custom headers or manually constructing messages via SMTP.

The main symptom of header formatting errors is hard bounces with vague error codes, or mail that silently disappears. If you're seeing "message rejected due to policy violation" or "syntax error in header" bounce messages, check your headers. Our free email header analyzer will show you exactly what receiving servers see, including formatting issues.

One last thing: if you're building your own mail sending infrastructure or debugging bounces, learn to read raw headers. That's where these errors show up.

Contributors

Who worked on this answer

Every name links to their profile. Every company links to their site. Real people, real accountability.

Ask an AI · tailored to your setup

Get Personalized Header Advice

I read this on the Email Almanac about email header formatting pitfalls: "Email headers need very specific formatting (RFC 5322 standard). Common mistakes include missing colons after field names, using wrong line breaks (\n instead of \r\n), extra spaces before or inside field names, badly quoted display names with special characters, duplicate fields that shouldn't be duplicated (like multiple From: headers), and headers that exceed 78 characters without proper folding. ESPs handle this automatically, but if you're sending via custom SMTP or adding custom headers, these errors cause hard bounces or silent rejections." Help me understand how this applies to MY specific situation. Based on what you share below, I'll give you: 1. Whether your setup is at risk for header formatting errors 2. What specific fields or configurations to check 3. How to test if your headers are valid 4. When to escalate to your ESP or a developer --- My details (the more you share, the better the advice): - Email platform/ESP: [e.g. Mailchimp, SendGrid, custom SMTP server, WordPress plugin] - Are you adding custom headers? yes/no, and which ones - Sending method: ESP dashboard, API, direct SMTP, mail merge tool - What prompted this: [bounce messages, deliverability drop, building custom integration] - Bounce error codes (if any): paste the exact error message - Experience level: beginner / intermediate / advanced

Edit the yellow boxes, then send to the AI of your choice.