Skip to content

Instantly share code, notes, and snippets.

@JamieWritesCode
Last active August 23, 2016 06:33
Show Gist options
  • Save JamieWritesCode/9a54590c97e378b9c1ba4c5d8a3255df to your computer and use it in GitHub Desktop.
Save JamieWritesCode/9a54590c97e378b9c1ba4c5d8a3255df to your computer and use it in GitHub Desktop.
Wordpress function to configure PHPMailer to use SMTP
add_action( 'phpmailer_init', 'wph_phpmailer_init' );
function wph_phpmailer_init( PHPMailer $phpmailer ) {
$phpmailer->IsSMTP();
$phpmailer->setFrom('NOREPLY@DOMAIN.COM', 'WEBSITE'); // default from address
$phpmailer->SMTPAuth = true; // enable SMTP authentication
$phpmailer->Port = 587; // set the SMTP server port
$phpmailer->Host = 'SMTP_HOST'; // SMTP server
$phpmailer->Username = 'SMTP_USERNAME'; // SMTP server username
$phpmailer->Password = 'SMTP_PASSWORD'; // SMTP server password
$phpmailer->SMTPSecure = 'tls';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment