PHP、PHPMailer:无法获取 PHPMailer 工作的示例代码
我正在尝试让 php 邮件程序正常工作。我收到错误,但无法从谷歌找到任何相关信息。
$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);
如果有人可以提供帮助,我们将不胜感激!谢谢。
I'm trying to get php mailer to work. I'm getting an error but couldn't find any info from google on it.
$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
The code above is what I'm using but when I try to run it I get the following in my browser...
Fatal error: Cannot access empty property in /the/full/path/to/phpmailer.inc.php on line 271
Here is the line it's referring to...
$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding);
If anyone can help it would be greatly appreciated! Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Encoding
不是变量:$this->Encoding
Encoding
is not a variable:$this->Encoding
文件 phpmailer.inc.php 中的第 271 行有错误
该行是:
将其更改为:
There's an error on line 271 in file phpmailer.inc.php
The line is :
Change it for :
您确定要
$this->$Encoding
吗?我认为你想要$this->Encoding
(注意 Encoding 上缺少 $)。Are you sure you want
$this->$Encoding
? I think you want$this->Encoding
(note the lack of $ on Encoding).