Xampp PHPMailer没有';无法在Windows Server 2012中工作-无法与Gmail、Yahoo等进行中继。。。

Xampp PHPMailer没有';无法在Windows Server 2012中工作-无法与Gmail、Yahoo等进行中继。。。,xampp,smtp,phpmailer,windows-server-2012,sendmail.exe,Xampp,Smtp,Phpmailer,Windows Server 2012,Sendmail.exe,我的Windows Server 2012中的PHPMailer有问题。我正在使用XAMPP作为本地服务器。我注意到我无法在Windows server 2012中ping smtp.gmail.com。上面说 ping request could not find host smtp.gmail.com. Please check and try again 我在php.ini [mail function] smtp_server=smtp.gmail.com smtp_port=25 s

我的Windows Server 2012中的PHPMailer有问题。我正在使用XAMPP作为本地服务器。我注意到我无法在Windows server 2012中ping smtp.gmail.com。上面说

ping request could not find host smtp.gmail.com. Please check and try again
我在
php.ini

[mail function]
smtp_server=smtp.gmail.com
smtp_port=25
sendmail_path ="\"D:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=example@gmail.com
auth_password=password
force_sender=
force_recipient=
hostname=localhost
我在
sendmail.ini

[mail function]
smtp_server=smtp.gmail.com
smtp_port=25
sendmail_path ="\"D:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=On
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
debug_logfile=debug.log
auth_username=example@gmail.com
auth_password=password
force_sender=
force_recipient=
hostname=localhost
我在本地PC上测试了我的PHP编译器,它工作得很好。我可以向自己的域发送电子邮件(“example@pn.com)和其他域电子邮件,如test@gmail.com, test@yahoo.com等等,这是我的PHPMailer代码

testsend.php

<?php
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "example@gmail.com";
$mail->Password = "password";
$mail->setFrom('test@gmail.com', 'First Last');
//$mail->addReplyTo('replyto@example.com', 'First Last');
$mail->addAddress('test@gmail.com', 'John Doe');
$mail->Subject = 'PHPMailer GMail SMTP test';
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->Body = 'dfssf';
$mail->AltBody = 'This is a plain-text message body';
//$mail->addAttachment('images/phpmailer_mini.png');
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}
如何解决这个问题


谢谢。

听起来您的ISP正在阻止出站SMTP(这很常见),并将您重定向到他们自己的邮件服务器,而您的凭据不起作用。我建议询问您的ISP或咨询他们的文档。此外,
tls
/
465
组合将不起作用-将端口587用于tls。阅读PHPMailer故障排除指南,并根据提供的示例编写代码。已将其更改为“587”,但仍然无效。我说的其他事情也是如此。