Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cranca
Forked from butlerblog/wp_config.php
Created April 12, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cranca/e689abbbf6523b5b809fe18fefd39e67 to your computer and use it in GitHub Desktop.
Save cranca/e689abbbf6523b5b809fe18fefd39e67 to your computer and use it in GitHub Desktop.
Configure WordPress wp_mail function to send through SMTP server http://b.utler.co/Y3
/**
* This function will connect wp_mail to your authenticated
* SMTP server. This improves reliability of wp_mail, and
* avoids many potential problems.
*
* Author: Chad Butler
* Author URI: http://butlerblog.com
*
* For more information and instructions, see:
* http://b.utler.co/Y3
*/
add_action( 'phpmailer_init', 'send_smtp_email' );
function send_smtp_email( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "smtp.example.com";
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = true;
// SMTP port number - likely to be 25, 465 or 587
$phpmailer->Port = "587";
// Username to use for SMTP authentication
$phpmailer->Username = "yourusername";
// Password to use for SMTP authentication
$phpmailer->Password = "yourpassword";
// Encryption system to use - ssl or tls
$phpmailer->SMTPSecure = "tls";
$phpmailer->From = "you@yourdomail.com";
$phpmailer->FromName = "Your Name";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment