Skip to content

Instantly share code, notes, and snippets.

@ivankristianto
Created December 14, 2016 00:18
Show Gist options
  • Save ivankristianto/d55bd91d6f05243638af61350493ddd8 to your computer and use it in GitHub Desktop.
Save ivankristianto/d55bd91d6f05243638af61350493ddd8 to your computer and use it in GitHub Desktop.
wp_mail() log error and smtp setting
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