简体   繁体   English

无法连接到SMTP主机。 邮件错误:SMTP错误:无法连接到SMTP主机

[英]Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host

I'm using PHPMailer for sending mail with authentication, but i'm getting the following message when i tried to run my sendmessage.php. 我正在使用PHPMailer通过身份验证发送邮件,但是当我尝试运行sendmessage.php时收到以下消息。

SMTP -> ERROR: Failed to connect to server: Connection timed out (110) 
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

can anyone please tell me why i'm getting this message...and some solution for this 谁能告诉我为什么我收到此消息...以及对此的一些解决方案

Mycode is as given below Mycode如下

sendmessage.php sendmessage.php

<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>

<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded


$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "myemailid@gmail.com";
$mail->Password = "myemailpassword";
$mail->SetFrom('myemailid@gmail.com','vgvb');
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress('myfriendemailid');
 if(!$mail->Send())
    {
    echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
    echo "Message has been sent";
    }
?>

</body>
</html>

从WAMP中打开php.ini文件,并验证unes注释。

尝试这个

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

问题可能是您的防火墙阻止了smtp.gmail.com,而是提供了它应该工作的IP地址

74.125.129.108

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SMTP错误:无法连接到SMTP主机。邮件程序错误:SMTP错误:无法连接到SMTP主机 - SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host SMTP错误:无法连接到SMTP主机。 - SMTP Error: Could not connect to SMTP host. PHPMailer 使用 Gmail 作为 SMTP 服务器。无法连接到 SMTP 主机。 邮件程序错误:SMTP 错误:无法连接到 SMTP 主机 - PHPMailer to use Gmail as SMTP server.Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host SMTP 错误:无法连接到 SMTP 主机。 phpmailer 错误 - SMTP Error: Could not connect to SMTP host. Phpmailer error 如何解决“SMTP错误:无法连接到SMTP主机”。 在phpmailer中? - How to resolve 'SMTP Error: Could not connect to SMTP host.' in phpmailer? SMTP错误:无法连接到SMTP主机。 亚马逊电子邮件服务 - SMTP Error: Could not connect to SMTP host. Amazon email service SMTP错误:无法连接到SMTP主机。 不工作 - SMTP Error: Could not connect to SMTP host. not working php mailer SMTP错误:无法连接到SMTP主机 - php mailer SMTP Error: Could not connect to SMTP host SMTP-&gt;错误:无法连接到服务器:连接超时(110)SMTP错误:无法连接到SMTP主机。 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. PHPMailer,SMTP错误无法连接到smtp主机 - PHPMailer,SMTP Error Could not connect to smtp host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM