我可以从本地服务器发送电子邮件。但是,当我尝试从网络服务器发送电子邮件时,显示以下消息:消息未发送邮件程序错误:语言字符串加载失败:connect_host
这是我的代码:
<?php
require("class.phpmailer.php");
$name=$_POST['name'];
$company=$_POST['company'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$subject=$_POST['subject'];
$question=$_POST['question'];
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.gmail.com';
$mailer->Port = 465; //can be 587
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'info.dhuronto@gmail.com'; // Change this to your gmail address
$mailer->Password = '*********'; // Change this to your gmail password
$mailer->From = 'info.dhuronto@gmail.com'; // Change this to your gmail address
$mailer->FromName = 'Client'; // This will reflect as from name in the email to be sent
$mailer->Body = "Name :".$name."\n\nCompany :".$company."\n\nEmail :".$email."\n\nPhone :".$phone."\n\n\n".$question."";
$mailer->Subject = $subject;
$mailer->AddAddress('support@dhuronto.com'); // This is where you want your email to be sent
/*$mailer->AddAttachment('attach_file/'.$_FILES["file"]["name"]);*/
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
header ('Location:index.html');
}
?>