Created
December 14, 2016 00:18
-
-
Save ivankristianto/d55bd91d6f05243638af61350493ddd8 to your computer and use it in GitHub Desktop.
wp_mail() log error and smtp setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('wp_mail_failed', 'log_mailer_errors', 10, 1); | |
function log_mailer_errors($mailer){ | |
$fn = ABB_FRAMEWORK . 'mail.log'; // say you've got a mail.log file in your server root | |
$fp = fopen($fn, 'a'); | |
fputs($fp, "Mailer Error: " . json_encode($mailer->get_error_messages()) ."\n"); | |
fclose($fp); | |
} | |
add_action( 'phpmailer_init', 'mailer_config', 10, 1); | |
function mailer_config(PHPMailer $mailer){ | |
$mailer->IsSMTP(); | |
$mailer->SMTPAuth = true; | |
// $mailer->SMTPSecure = 'ssl'; | |
$mailer->Host = 'host'; | |
$mailer->Port = 465; | |
$mailer->SMTPDebug = 2; | |
$mailer->Username = 'xxxxx'; | |
$mailer->Password = 'xxxxx'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment