Skip to content

Instantly share code, notes, and snippets.

@sorich87
Created April 15, 2012 13:42
Show Gist options
  • Save sorich87/2392858 to your computer and use it in GitHub Desktop.
Save sorich87/2392858 to your computer and use it in GitHub Desktop.
Send WordPress emails via SMTP
function my_phpmailer_init( $phpmailer ) {
if ( ! defined( 'SMTP_HOST' ) )
return;
$phpmailer->IsSMTP();
$phpmailer->Host = SMTP_HOST;
$phpmailer->Port = defined( 'SMTP_PORT' ) ? SMTP_PORT : 25;
if ( defined( 'SMTP_USER' ) ) {
$phpmailer->SMTPAuth = true;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = defined( 'SMTP_PASSWORD' ) ? SMTP_PASSWORD : '';
}
if ( defined( 'SMTP_SECURE' ) )
$phpmailer->SMTPSecure = SMTP_SECURE;
if ( defined( 'SMTP_DEBUG' ) && SMTP_DEBUG )
$phpmailer->SMTPDebug = true;
}
add_action( 'phpmailer_init', 'my_phpmailer_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment