调用phpmailer发邮件,在本地没问题,放到goddady就出以下错误,有人遇到过吗?请帮忙一下。
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.我的代码: $to="[email protected]";
$body="only a test!";
error_reporting(E_STRICT);
date_default_timezone_set("Asia/Shanghai");
require_once('class.phpmailer.php');
include("class.smtp.php");
$mail = new PHPMailer();
$body = eregi_replace("[\]",'',$body);
$mail->CharSet ="UTF-8";
$mail->IsSMTP();
$mail->SMTPDebug = 1;
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "SMTP.gmail.com";
$mail->Port = 25;
$mail->Username = "[email protected]"; // email address
$mail->Password = "xxxxxx"; // email password
$mail->SetFrom('[email protected]', 'lee');
$mail->Subject = $subject;
$mail->AltBody = "test";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, "");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.我的代码: $to="[email protected]";
$body="only a test!";
error_reporting(E_STRICT);
date_default_timezone_set("Asia/Shanghai");
require_once('class.phpmailer.php');
include("class.smtp.php");
$mail = new PHPMailer();
$body = eregi_replace("[\]",'',$body);
$mail->CharSet ="UTF-8";
$mail->IsSMTP();
$mail->SMTPDebug = 1;
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "SMTP.gmail.com";
$mail->Port = 25;
$mail->Username = "[email protected]"; // email address
$mail->Password = "xxxxxx"; // email password
$mail->SetFrom('[email protected]', 'lee');
$mail->Subject = $subject;
$mail->AltBody = "test";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, "");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
发现很多人遇到这个问题主要的原因是相关端口没有打开
连接到smtp服务器,端口基本都是不开的