Troubleshooting: WordPress Contact Form Not Sending EMail

I was ready to call it a day after long hard-working hours, then a unhappy customer dropped me a bomb, “Hey, the contact form you just touched today not sending out email. Get it fixed, NOW!”. If this sounds familiar to you, then you shouldn’t be panic.

Despite of the changes I made to the form plugin was CSS related, as the first response, I test the contact form. By replacing the responding email address to mine, I submit a request through contact form. And NO, there is no incoming email in my inbox. But there is also another indicator, the contact form works fine, no error. I get the normal confirmation message after click the submit button. Which means, the plugin works normal.

The following step is simple. I should check the hosting server’s mail server. To do so, I use a short php send email snippet. It is always there in my toolbox. I just drag and drop it into the root directory of the client’s website via FTP.

<?php
// Sendemail.php

// The receiver's email address
$to = 'youremail@yourdomain.com';

// Email subject
$subject = 'Send email test';

// Email message
$message = "Hello Administrator!\n\nThis is a test email sent from ".$_SERVER['HTTP_HOST']." on ".date('D, d M Y H:i:s').".";

// Define the headers  
$headers = "From: administrator@yourdomain.com
Reply-To: administrator@yourdomain.com";

// Send the email
$mail_sent = @mail( $to, $subject, $message, $headers );

// Is the message out?
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

To test, change the $to, $header with proper email address, and call the script directly from browser:

http://yourdomain.com/sendemail.php

Again, I got “Mail sent” message, but no email in my inbox.

Now, everything is clear. It is the mail server causing the delay. Because email has been sent out properly by the contact form plugin. Independent PHP script approved this as well.

The web site may be hosted on a shared server with many other web sites. The mail server could be overloaded. When the mail server has many requests for sending email, the emails are held in a Mail queue and sent out a one at a time. An overloaded server with many mail requests will cause a delay in sending mail.

If your mail is being delayed, the best thing to do is to contact the hosting company. You may also choose to ignore it, because the emails are not lost, but just delayed. In my past incidents, the emails showed up hours (even days) later.

* Please be advised that, on some hosting servers, as anti-spoofing policy, the From: address must be set to a real email account hosted by the hosting company.