I am developing a WordPress site on a vagrant box and have installed postfix in order to test email notifications.

At this guest OS (Ubuntu) level, I am able to end a test email:

echo "Test mail from postfix" | mail -s "Test Postfix" [email protected]

This works and I receive the email. As far as I know postfix uses the sendmail binary and so I would expect WordPress to send emails successfully.

However, my contact form notifications are not being received. Is there a way to check/debug email sending in WordPress or verify which mail function it is using?


So after a bit of digging I discovered that wp_mail() uses PHPMailer. If I debug the wp_mail() function using this test script I see that PHPMailer is throwing an exception:

Could not instantiate mail function.

// Set $to as the email you want to send the test to
$to = "[email protected]";

// No need to make changes below this line

// Email subject and body text
$subject = 'wp_mail function test';
$message = 'This is a test of the wp_mail function: wp_mail is working';
$headers[] = 'From: Me Myself <[email protected]>';

// Load WP components, no themes
define('WP_USE_THEMES', false);

// Call the wp_mail function, display message based on the result.
if( wp_mail( $to, $subject, $message, $headers ) ) {
    // the message was sent...
    echo 'The test message was sent. Check your email inbox.';
} else {
    // the message was not sent...
    echo 'The message was not sent!';
  • What is the output of ini_get( 'sendmail_path' );? By default it should be pointing to a local sendmail binary/link, for example /usr/sbin/sendmail. Make sure it exists and is pointing to your Postfix binary.
    – kovshenin
    Aug 5, 2016 at 22:42

1 Answer 1


WordPress uses the wp_mail() function to send mail. It says on the Codex article there that:

For this function to work, the settings SMTP and smtp_port (default: 25) need to be set in your php.ini file.

Also be sure to check that your contact form is sending the required parameters to the wp_mail() function. The required parameters are included on the page in the link above.

  • Thanks. This does seem to be the case. However, on this particular setup, I have postfix installed and the SMTP information in stored in the postfix config. I can't seem to find any decent information on how to configure PHP to use that config,
    – codecowboy
    Feb 11, 2015 at 7:40
  • I am having a similar issue please see serverfault.com/questions/803491/…
    – JoaMika
    Sep 16, 2016 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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