0

我可以从本地服务器发送电子邮件。但是,当我尝试从网络服务器发送电子邮件时,显示以下消息:消息未发送邮件程序错误:语言字符串加载失败: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');
        }
?>
4

2 回答 2

0

尝试将所有 PHPmailer 文件上传到您的网络服务器。您可能忘记了语言文件夹。

您可能还需要设置语言:

$mail = new PHPMailer();
$mail->SetLanguage( 'en', 'phpmailer/language/' );
于 2013-01-09T20:14:49.160 回答
0

我认为您必须在脚本中设置语言,例如

<?php
require("class.phpmailer.php");
SetLanguage('en','phpmailer/language/');

$name=$_POST['name'];
$company=$_POST['company'];
$email=$_POST['email'];
于 2013-01-09T20:16:16.417 回答