WordPress sends email when performing many built-in actions like registering a new user, resetting a password, or even notifying the administrator of a new comment or trackback. Contact form plugins like Gravity Forms and Contact Form 7 use wp_mail
, so their messages are sent in the same manner.
If you use an external email service like Microsoft Exchange or Google Apps for Work, you can route everything through that service to speed up mail delivery, and help ensure that all of your emails come through.
This can be done by placing a bit of code in your theme’s functions.php
file:
function send_via_smtp( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->SetFrom("[email protected]", "From Name");
$phpmailer->AddReplyTo("[email protected]", "Reply-To Name");
$phpmailer->Host = "smtp.domain.com";
$phpmailer->SMTPAuth = true; // require smtp authentication?
$phpmailer->SMTPSecure = true; // security protocol (true/false or "tls")
$phpmailer->Port = 587; // port depends on security and server setup
$phpmailer->Username = "[email protected]";
$phpmailer->Password = "YOURPASSWORD";
}
add_action( "phpmailer_init", "send_via_smtp" );
Just get your SMTP settings from your web host or email administrator and replace the values above. If your server doesn’t require SMTP authentication, you can exclude the username and password lines.