I am trying to set custom From name and email in wp_mail headers but somehow, wp_mail ignores the name but gets the email correctly.

This is the headers code I am using.

$headers = array(
    'Content-Type: text/html; charset=UTF-8',
    'From: Michelle Titus <titus@brazilbr.com>'

I am not using such plugins which can alter the data. However, I am using GravityForms which I don't think should conflict with what I have here.

I cannot use the wp_mail_from_name and wp_mail_from_email because the wp_mail is called dynamically with different From data each time. Maybe I can put some conditional logic but I thought I should ask for a better solution.

And there's no question resembling my issue anywhere, as far as I searched Google.



Is there an actual titus@brazilbr.com email address? And (more importantly) is the brazilbr.com the domain name of your site? If not, then your hosting place will ignore the 'from' email when it processes the wp_mail() command.

You need to make sure that the 'from' email address you use in wp_mail() is an email address on the domain for your site. If needed, created an email account on your domain, then use forwarding rules to get it to the titus@brazilbr.com email address.

You can also set the 'reply-to' in the mail header to whatever you want. But the sender email must match the domain of the site that is sending the mail. If not, the mail will get delivered, but will not have the 'from' address you specified. And, some mail clients might block your email as spam, since the sender email doesn't match the sender domain.

  • Makes sense. Thank you for your prompt response. I'll go through your suggestions and come back if I face any other obstacle. – Junaid Jul 30 '17 at 0:33
  • 1
    No problem. Been there before, then learned why. (If an answer is correct for your question, using the checkmark tells others of a correct answer.) I usually create an email for the domain, then forward it to my primary (gmail) account. I don't worry about replies from the primary account not matching the domain name. – Rick Hellewell Jul 30 '17 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.