我使用PHPMailer
发送具有身份验证的邮件,但是当我尝试运行我的sendmessage.php时收到以下消息。无法连接到SMTP主机。邮件错误:SMTP错误:无法连接到SMTP主机
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.
谁能告诉我为什么我得到这个消息,和这
mycode的一些解决方案如下
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 = "[email protected]";
$mail->Password = "myemailpassword";
$mail->SetFrom('[email protected]','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>
给出
贵启用主机服务器上的端口465进行沟通?有些主机不允许你发送邮件。 –
我们是否有默认情况..........如何检查 – user3159579
您将不得不打电话或通过电子邮件发送您的托管服务提供商。 –