PHP, PHPMailer: Can't get example code for PHPMailer to work

风格不统一 提交于 2019-12-08 03:39:48

问题


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 = "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

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.


回答1:


Encoding is not a variable: $this->Encoding




回答2:


There's an error on line 271 in file phpmailer.inc.php

The line is :

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

Change it for :

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



回答3:


Are you sure you want $this->$Encoding? I think you want $this->Encoding (note the lack of $ on Encoding).



来源:https://stackoverflow.com/questions/4653259/php-phpmailer-cant-get-example-code-for-phpmailer-to-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!