BlueHost and WordPress wp_mail Issues

Bluehost wp_mail issue

Yesterday while working on a client website, I came across a peculiar problem that I had not yet faced. Bluehost scripted mail is a tightly controlled process unlike with other web hosts. You cannot send a mail unless you have a “Valid From Header”.


How WordPress Contact Forms Work

WordPress relies on phpmailer architecture to send and receive mails, as well as for SMTP configuration. I am sure you are already aware of this. But did you know that while wp_mail is responsible for the process of sending an email, it depends on your webhost as to whether they wish to send the message out or not. Case in point is Bluehost and their Valid From Header requirement.

If you find that your contact form says it has successfully sent a mail but you do not receive it in the designated email then most of the time it is the host at fault or rather their stringent requirements. The first and foremost thing to do is check if wp_mail is working. Here is a neat script I found online to do the test. Make sure you either login to the file manager on your hosting panel and navigate to the root of your wordpress installation or you use FTP. Then create a new file named mailtest.php with the wp_mail test code here. Open up the test by typing in in the browser URL bar to diagnose if it your wp_mail php function is working.

Either you get a mail sent successful message or a failure message. If it is a failed message then your wp_mail is not working. Best solution is to copy the function.php file from your template zip folder directly onto the parent theme of your wordpress installation and then recheck.

A successful message almost always means that your web host needs a valid from header.

Valid From Header

Bluehost and wordpress wp_mail problems are always the valid from header type. Basically it means that your host needs all server-side email scripts to send with the header containing an additional text segment that gives the “from” address and it has to be a valid email address. By valud this means that the email address needs to be made using the email tab of your host’s control panel first. By default WordPress relies on the following From header:

From: WordPress <

Because you have not made an email account by the name of in your control panel, it is not yet valid. Hence the need to make it.

The simplest approach is to just make the email address in your host’s control panel. That almost always takes care of this issue. If this does not work then make a different email address and copy the following lines of code into your function.php file under Appearance -> Editor window of your WordPress admin screen.

add_filter( 'wp_mail_from', 'my_mail_from' );
function my_mail_from( $email )
    return "change-this-to-your-email-address";

add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
function my_mail_from_name( $name )
    return "My Name";

Save and that should do it. With Bluehost you need to follow all of these steps to get contact form plugins such as Contact Form 7 and others working. This is also a quick fix for theme specific contact form issues with certain hosts. Avada for instances has this issue with Bluehost and is easily fixed applying these patches.


Hope you liked my explanation and I could be of help. Please bookmark my site and this page!

Leave a Reply