我可以从本地服务器发送电子邮件。但是当我尝试从网络服务器发送电子邮件时,请显示以下消息: 消息未发送 邮件程序错误:语言字符串无法加载: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');
}
?>
答案 0 :(得分:0)
尝试将所有PHPmailer文件上传到您的网络服务器。您可能忘记了语言文件夹。
您可能还需要设置语言:
$mail = new PHPMailer();
$mail->SetLanguage( 'en', 'phpmailer/language/' );
答案 1 :(得分:0)
我认为您必须在脚本中设置语言,如
<?php
require("class.phpmailer.php");
SetLanguage('en','phpmailer/language/');
$name=$_POST['name'];
$company=$_POST['company'];
$email=$_POST['email'];