我尝试了在 win server 2012 r2 相关答案中提示的所有步骤,包括其相关答案和特定的 PHPMailer。
但是,我仍然遇到同样的问题。此外,已检查端口 25 是否在此处运行防火墙问题。
如果有人可以帮助我,真的很感激。
注意:
Win server 2012 r2 相关答案
PHPMailer答案
服务器故障解答 谢谢
更新
//To test is via basic mail function
/*
mail("from_to_email@example.com", "Test Subject", "Test Message");
*/
//To Test via PHPMailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/phpmailer/phpmailer/src/Exception.php';
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/phpmailer/src/SMTP.php';
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from_email@example.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("to_email@example.com"); //Tried $mail->addAddress("to_email@example.com", "test name"); and third param too.
//Send HTML or Plain Text email
$mail->isHTML(true); //Tried with false too.
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPDebug = 3;
$mail->SMTPSecure = 'ssl';
// optional
// used only when SMTP requires authentication
$mail->SMTPAuth = true;
$mail->Username = SMTP_EMAIL_HERE;
$mail->Password = SMTP_PASS_HERE;
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
甚至,我通过在线 SMTP 工具尝试了我的 SMTP 凭证,它工作正常,但上面的代码不是。
注意:我验证了 PHP/Apache 模块的可用性,并且模块没有问题。