php mailer Mailer Error:语言字符串加载失败:connect_host?

时间:2010-09-01 11:24:23

标签: php email send phpmailer

我一直收到这个错误..

下面是我的代码:

<?php
ini_set("include_path", "phpmailer/"); 
require 'phpmailer/class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'smtp.gmail.com';
$mailer->Port='465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'mail@gmail.com';  // Change this to your gmail adress
$mailer->Password = '****';  // Change this to your gmail password
$mailer->From = 'maile@gmail.com';  // This HAVE TO be your gmail adress
$mailer->FromName = 'Belmer'; // This is the from name in the email, you can put anything you like here
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('another@ymail.com');  // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
   echo "Message has been sent";
}
?>

有人知道这个错误吗?非常感谢您的回复。

1 个答案:

答案 0 :(得分:0)

知道了!谢谢你们观看。

代码实际上没有问题,它必须是我本地服务器上的一些设置。我的解决方案是我将文件上传到我的实时网络服务器,一切正常。