PHPMailer Gmail SMTP可在localhost上运行,但不在服务器上运行

时间:2012-12-05 14:27:05

标签: php smtp gmail phpmailer

这是我在生产服务器上运行PHPMailer脚本时得到的结果。 PHPMailer版本 5.1

SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error:
Could not connect to SMTP host

PHPMailer配置

$mail->IsSMTP();
$mail->SMTPDebug  = 1;
$mail->SMTPAuth   = true;                  
$mail->SMTPSecure = "ssl";                 
$mail->Host       = "smtp.gmail.com";      
$mail->Port       = 465;                   
$mail->Username   = "xxxx@gmail.com";  
$mail->Password   = "xxxx";

使用此配置,它在运行XAMPP的localhost上完美运行。

我尝试过什么

$mail->SMTPSecure = "tls"; // no luck

$mail->Host = "ssl://smtp.gmail.com"; // no luck

$mail->SMTPKeepAlive = true; // no luck

$mail->Port = 587; // no luck

$mail->Port = 25; // no luck

我尝试了上述的各种组合,但仍然显示上面显示的错误消息。

仅供参考,我的localhost在Windows上,而服务器在Linux上。不知道这是否会引起问题,但只是想把它放在那里。

0 个答案:

没有答案
相关问题