问题如下:
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";
} 希望谁能告诉我到底是怎么回事?
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";
} 希望谁能告诉我到底是怎么回事?
/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;
}
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;
}