2011-01-11 90 views
1

我试图让PHP邮件程序工作。我收到一个错误,但无法从Google上找到任何信息。PHP,PHPMailer:无法获取PHPMailer的示例代码来工作

$mail = new phpmailer; 

$mail->IsSMTP(); // set mailer to use SMTP 
$mail->SMTPSecure = "ssl"; 
$mail->Host = "smtp.gmail.com"; 
$mail->Port = 465; 

$mail->From = "[email protected]"; 
$mail->FromName = "Mailer"; 
$mail->AddAddress("[email protected]", "User"); 
//$mail->AddAddress("[email protected]"); // name is optional 
$mail->AddReplyTo("[email protected]", "Information"); 
$mail->WordWrap = 50; // set word wrap 
//$mail->AddAttachment("c:\\temp\\js-bak.sql"); // add attachments 
//$mail->AddAttachment("c:/temp/11-10-00.zip"); 

$mail->IsHTML(true); // set email format to HTML 
$mail->Subject = "Here is the subject"; 
$mail->Body = "This is the message body"; 
$mail->Send(); // send message 

上面的代码是我使用的是什么,但是当我尝试运行它,我得到我的浏览器下...

Fatal error: Cannot access empty property in /the/full/path/to/phpmailer.inc.php on line 271 

这里是它指的是行...

$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding); 

如果有人能帮助它将不胜感激!谢谢。

+1

你检查了`$ this-> Encoding`吗?我不认为`Encoding`是一个变量。 – Ben 2011-01-11 01:15:25

回答

6

Encoding不是一个变量:$this->Encoding

+2

疯了,好吧,我从他们的网站下载了它,我想他们搞砸了,因为我没有编辑该文件。谢谢您的帮助。 – daveomcd 2011-01-11 01:22:33

2

您确定要$this->$Encoding?我想你想要$this->Encoding(注意编码缺少$)。

+1

感谢您的帮助没有注意到它,我没有编辑他们的文件,所以我没有真正检查它。肯定今天学到了一些东西:) – daveomcd 2011-01-11 01:23:14

4

有文件phpmailer.inc.php在第271行的错误

该生产线是:

$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding); 

更改它:

$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->Encoding);