Error: InvalidInternetMessageHeader (Microsoft 365)
Microsoft Graph refused a custom header added to the email. Find the plugin adding it, then fix or remove that header.
This article is for sites using the 365 / Outlook mailer (Microsoft Graph) where some or all emails fail with InvalidInternetMessageHeader.
The error as you see it
InvalidInternetMessageHeader: The internet message header name '…' should start with 'x-' or 'X-'. (other versions name a header value that is not allowed)
Shown by the 365 / Outlook mailer, in the failed-send banner, in Tools → Debug Events and in the Email Log.
What this error means
WordPress plugins can add extra lines, called headers, to an email: tracking IDs, list information, priority flags and so on. Microsoft Graph is strict about them. It only accepts custom headers whose names begin with x-, accepts only a few of them per message, and checks their values. CRM-NG SMTP already passes on only headers starting with x-, at most five, and cleans their values. When Graph still rejects one, the header's name or value breaks one of Graph's other rules, and the whole message is refused.
Common causes
- A header value Graph does not accept: very long, empty, containing line breaks, or using characters outside plain text.
- The same header name twice in one message.
- A header name with unusual characters, such as spaces or accented letters.
- A form, newsletter or membership plugin that adds its own tracking headers to every email it sends.
Because headers come from whichever plugin created the email, the error often hits only certain emails, for example form notifications, while the test email works.
How to fix
- Confirm the connection works
Go to CRM-NG SMTP → Tools → Email Test, fill in Send To and press Send Email. The test email has no custom headers, so if it succeeds your Microsoft 365 setup is fine.
- Read the full error
Open CRM-NG SMTP → Tools → Debug Events and find the Email Sending Errors entry. Graph names the header it refused.
- See which email carried it
Turn on Store email bodies and headers on CRM-NG SMTP → Settings → Email Log (with Enable local email logging on) and press Save Local Logging Settings. Trigger the failing email again, then open its log entry to see its headers and subject.
- Find the source plugin
The subject and header name usually tell you which plugin sent the email. Check that plugin's settings for options such as custom headers, tracking or list headers, and turn off or correct the offending one.
- Isolate if unclear
If you cannot tell, follow Testing for plugin and theme conflicts on a staging copy until the header disappears.
- Test the real email
Trigger the email that failed (for example, submit the form) and check that it arrives.
Verify it worked
The email that failed now appears in the Email Log with a sent status, and Tools → Debug Events shows no new InvalidInternetMessageHeader entries.
Notes
- After you finish, consider turning Store email bodies and headers off again: stored emails may hold personal data and password reset links.
- If you rely on a header that Graph will never accept, the 365 / Outlook mailer cannot carry it. Choose a mailer for that site whose service accepts the header.
