Contact Form Messages DMARC Error

I had an interesting problem this week where a client of mine said she was not receiving email messages via her website contact form. I quickly brought up the site and submitted a form successfully. The email went through OK. So I was all like “What the heck are you talkin’ about lady?!?!” and said things worked fine.

After a few days, she contacts me again, insisting there is an issue with her contact form. Again I test it, and it works fine. But this time, I had a look at her email delivery log and found a few failures that said

ECDHE-RSA-AES128-GCM-SHA256:128 CV=yes: SMTP error from remote mail server after end of data: 554 5.7.9 Message not accepted for policy reasons. See

All of these failures occurred when the website visitor used a yahoo email address in the form. Apparently there is a thing called DMARC that makes an email server reject messages that come from a different domain than the one specified in the email header. Google has a page about it.

So my form was sending email from my client’s domain, but the header said it was coming from Based on this, my clientâ’s Gmail service was rejecting the message.

Note: She has her email routed from the web server to a Gsuite email account.

How do you fix this?

In my case, the problem was with the PHP contact form. There was a portion of the form that set the email header that I had to change.

$header = "From: $Email\n";


$header = "From:\n";

By doing this, the form stops populating the header with information from the form, and just sends the email from

This affected when my client selected “reply”. So I had to add another line that controls the “Reply-To” address to fix that issue:

$header +="Reply-To: $Email\n";

This line takes the email address the user entered and makes it the address used to reply to.

I’m sure if you have this problem and are working with a contact form, it will look different. But hopefully my post points you in the right direction.

Leave a Comment