First, I already read this stack post, and it doesn't seem to answer my question. I'm unclear how to apply those findings to my situation.
The following code works fine on my LAMP
server (Bluehost), and I receive the email:
require_once("PHPMailer/src/Exception.php");
require_once("PHPMailer/src/PHPMailer.php");
require_once("PHPMailer/src/SMTP.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->SMTPDebug = 2; // verbose debug output
//$mail->SMTPDebug = 0; // no output
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = $mailSender;
$mail->Password = $mailSenderPassword;
$mail->SetFrom($mailSender);
$mail->addAddress($mailTo);
$mail->isHTML(true);
$mail->Subject = "email test";
$mail->Body = "testing an email";
$mail->send();
But on my local WIMP (Windows-IIS-MySQL-PHP) PC, I always get the following error when running it:
Failed to connect to server: (0)
Note: I run php pages successfully all the time on my WIMP pc. The only thing that doesn't work locally is PHPMailer
.
I tried turning my windows firewall completely off and that made no change.
How can I run this successfully on my Windows 10 IIS PC?