PHPMailer - email will not send, no error is displayed

Viewed 37

My code:

`<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;   
require 'PHPMailer-master/src/Exception.php';
require 'PHPMailer-master/src/PHPMailer.php';
require 'PHPMailer-master/src/SMTP.php';

 // I installed using the zip file, so I am not using autoloader

$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.office365.com";
$mail->SMTPDebug = 3;
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[ my Exchange email address ]";
$mail->Password = "[ my Exchange password ]";
$mail->setFrom("[ my Exchange email address ]", "[ my name ]");
$mail->addAddress("[ recipient email ]", " [ recipient name ]");
$mail->Subject = 'PHPMailer SMTP test';
$mail->msgHTML("test body");
$mail->AltBody = 'HTML messaging not supported';
if(!$mail->send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
echo "Message sent!";
}
?>`

The only output is:

2022-02-08 14:36:21 Connection: opening to smtp.office365.com:587,timeout=300, options=array()

There is no other output whatsover.

Other notes:

  • I am using PHPMailer version 6.5.3
  • I checked my outgoing SMTP connection from my local server at https://testconnectivity.microsoft.com/tests/exchange and no errors were reported. - The exchange account I am sending from does not have multifactor authentication enabled, so I do not need to use an app password.
  • I checked the login details for my email address. -I was using this code without issue until last Friday.
0 Answers
Related