I was working on my wife’s WordPress site tonight after she told me her contact form wasn’t working. I had been using the SMTP settings in php.ini to handle email across all the websites I support. But, I decided to stop using that because all emails were be coming from the same account, regardless of domain.
So, I started digging around and there is a plugin for WordPress called, aptly enough, WP Mail SMTP. This plugin is great because it allows me to set SMTP settings for individual sites, and it intercepts wp_mail() calls and sends them with the SMTP settings you give it.
This turned out to be my problem. The theme my wife uses has a built-in contact form, which was hard-coded to use mail() to send from the form. This no longer worked for me after I removed the SMTP settings from php.ini – even with the WP Mail SMTP plugin.
I started looking around at what exactly wp_mail() required to function. Here’s what the WordPress Codex says about what to pass it:
wp_mail($to, $subject, $message, $headers, $attachments);
Looks oddly like what the PHP Manual says about mail():
mail($to , $subject , $message, $additional_headers, $additional_parameters);
I tried changing the hard-coded mail() to wp_mail(), and there you go.