Home > Back-end >  PHPMailer suddenly fails sending
PHPMailer suddenly fails sending

Time:10-29

I just wanna ask if there's a workaround for this one. My phpmailer setup was working and was untouched until it fails sending about a week ago.

Here is my phpmailer config

$mail = new PHPMailer(true);
$mail->CharSet = "UTF-8";
$mail->isSMTP(); // Set mailer to use SMTP
$mail->SMTPDebug = 4; // Enable verbose debug output
$mail->Host = "smtp.office365.com"; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "secret"; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, ssl also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPOptions = array(
   'ssl' => array(
   'verify_peer' => false,
   'verify_peer_name' => false,
   'allow_self_signed' => true
   )
);

This is the debug output:

2021-10-28 08:38:24 Connection: opened
2021-10-28 08:38:24 SMTP INBOUND: "220 SJ0PR13CA0238.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 28 Oct 2021 08:38:24  0000"
2021-10-28 08:38:24 SERVER -> CLIENT: 220 SJ0PR13CA0238.outlook.office365.com Microsoft ESMTP MAIL Service ready at Thu, 28 Oct 2021 08:38:24  0000
2021-10-28 08:38:24 CLIENT -> SERVER: EHLO webapi.tanholdings.com
2021-10-28 08:38:25 SMTP INBOUND: "250-SJ0PR13CA0238.outlook.office365.com Hello [8.3.126.86]"
2021-10-28 08:38:25 SMTP INBOUND: "250-SIZE 157286400"
2021-10-28 08:38:25 SMTP INBOUND: "250-PIPELINING"
2021-10-28 08:38:25 SMTP INBOUND: "250-DSN"
2021-10-28 08:38:25 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2021-10-28 08:38:25 SMTP INBOUND: "250-STARTTLS"
2021-10-28 08:38:25 SMTP INBOUND: "250-8BITMIME"
2021-10-28 08:38:25 SMTP INBOUND: "250-BINARYMIME"
2021-10-28 08:38:25 SMTP INBOUND: "250-CHUNKING"
2021-10-28 08:38:25 SMTP INBOUND: "250 SMTPUTF8"
2021-10-28 08:38:25 SERVER -> CLIENT: 250-SJ0PR13CA0238.outlook.office365.com Hello [8.3.126.86]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2021-10-28 08:38:25 CLIENT -> SERVER: STARTTLS
2021-10-28 08:38:25 SMTP INBOUND: "220 2.0.0 SMTP server ready"
2021-10-28 08:38:25 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
SMTP Error: Could not connect to SMTP host.
2021-10-28 08:38:25 SMTP NOTICE: EOF caught while checking if connected
2021-10-28 08:38:25 Connection: closed
SMTP Error: Could not connect to SMTP host.```

CodePudding user response:

There has been a rash of issues relating to Outlook lately – I suspect that they have stopped supporting some old TLS versions, and old PHP configurations that only have support for those old protocols will stop working. I think they are rolling this change out slowly across their many servers, so it will be be intermittent, but will happen increasingly often.

The solution is to update your PHP version.

  • Related