Failed to send email through SMTP authentication.
-
Hi all,
I am using PHPMailer for smtp authentication to send emails. I have tried both options, secured and unsecured as provided by my hosting provider.
The problem looks like that the code does not recognize $phpmailer (i guess). The code is as below. (some of the information is fake here for
security purpose, but actual values are used in the code.):add_action( ‘phpmailer_init’, ‘configure_smtp’ );
function configure_smtp( PHPMailer $phpmailer ){
$phpmailer->isSMTP();
$phpmailer->Host = “mail.mydomain.net”;
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 25;
$phpmailer->Username = “[email protected]”;
$phpmailer->Password = “<password>”;
$phpmailer->From = “[email protected]”;
$phpmailer->FromName=”HRD”;
$phpmailer->SMTPSecure = false;
}and here’s the test code which sends mail:
$to = “[email protected]”;
$subject = “Checking email with smtp auth.”;
$message = “Please ignore this.”;
$ret = wp_mail($to, $subject, $message);
echo ‘—‘; //added just for debugging.
echo $ret;
echo ‘++++++++++’; //added just for debugging.
exit;Now it should echo —1++++++++++ whereas it always echoes —++++++++++ which means the mail could not be sent. I don’t know how to get the exact return/error code so that I can fix it. Also if i do not use PHPMailer at all the mails are sent successfully but they are reported as spam by the recipient servers to our hosting server as expected. So we have to authenticate through valid smtp credentials. Please help!
Thanks,
baburman
- The topic ‘Failed to send email through SMTP authentication.’ is closed to new replies.