我正在尝试让php邮件工作。我收到错误但无法从谷歌上找到任何信息。
$mail = new phpmailer;
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("user@theirsite.com", "User");
//$mail->AddAddress("ellen@site.com"); // name is optional
$mail->AddReplyTo("info@site.com", "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);
如果有人能提供帮助,我们将不胜感激!感谢。
答案 0 :(得分:6)
Encoding
不是变量:$this->Encoding
答案 1 :(得分:4)
文件phpmailer.inc.php
中的第271行有错误该行是:
$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding);
将其更改为:
$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->Encoding);
答案 2 :(得分:2)
您确定要$this->$Encoding
吗?我想你想要$this->Encoding
(注意编码时缺少$)。