问题如下:
Message was not sentMailer Error: Language string failed to load: connect_host
我的代码是:<?php
require("phpmailer/class.phpmailer.php"); 
$mail = new PHPMailer();
$mail->CharSet ="GB2312";
$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp.163.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = ""; // SMTP username
$mail->Password = ""; // SMTP password
$mail->From = "@163.com";
$mail->FromName = "";
$mail->AddAddress("@qq.com");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Here is the subject";
$mail->Body = '<meta http-equiv=content-type content="text/html; charset=GB2312">This is the <b>HTML body</b>支持中文';
$mail->AltBody = "This is the text-only body";
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: ".$mail->ErrorInfo;
exit;
}
else {
echo "Message has been sent";
} 希望谁能告诉我到底是怎么回事?

解决方案 »

  1.   

    这个办法也许行:找到这个文件:
    /lib/phpmailer/class.phpmailer.php 再找到这个函数:
    function AddrFormat($addr) {
    if(empty($addr[1]))
    $formatted = $addr[0];
    else
    {
    $formatted = $this->EncodeHeader($addr[1], ‘phrase’) . ” <” .
    $addr[0] . “>”;
    }
    return $formatted;
    }改成这样:function AddrFormat($addr) {
    $formatted = $addr[0];
    return $formatted;
    }
      

  2.   

    更正一下,不是从根目录开始找.应该在某个目录下面的lib/phpmailer/class.phpmailer.php
      

  3.   

    在下面修改一下就好了$this->SetLanguage('en'); // set the default language
      function SetLanguage($lang_type, $lang_path = 'language/') {
        if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
          include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
        } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
          include($lang_path.'phpmailer.lang-en.php');
        } else {
          $this->SetError('Could not load language file');
          return false;
        }
        $this->language = $PHPMAILER_LANG;    return true;
      }
      

  4.   

    这里有个写好的支持中文的例子,还有一个简单的函数http://cutso.blog.sohu.com/84261479.html