I’m getting this error message trying to use PHP Mailer. Please let me know if you see what is wrong.
Fatal error: Cannot access empty property in /hsphere/local/home/c263430/quoralist.com/includes/phpmailer/phpmailer.inc.php on line 271
Line 271 of phpmailer.inc.php is
$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding);
The code that called phpmailer.inc.php is
<?php
require_once("../includes/phpmailer/phpmailer.inc.php");
require_once("../includes/phpmailer/smtp.inc.php");
$to_name = "Junk Mail";
$to = "m73mit@gmail.com";
$subject = "Mail Test at ".strftime("%T", time());
$message = "This is a test.";
$message = wordwrap($message, 70);
$from_name = "Michael Mitchell";
$from = "michaeljohnmitchell@gmail.com";
//Php mail version (default)
$mail = new PHPMailer();
//$mail->IsSMTP();
//$mail->Host = "host"
//$mail->Port = 25;
//$mail->SMTPAuth = false;
//$mail->Username = "username";
//$mail->Password = "password";
$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = $message;
$result = $mail->Send();
echo $result ? 'Sent' : 'Error';
?>
EDIT
following a suggestion in one of the answers, I tried $this->Encoding instead of $this->$Encoding. When I ran it I got a new error message, not sure if it’s related.
Fatal error: Cannot redeclare class SMTP in /hsphere/local/home/c263430/quoralist.com/includes/phpmailer/smtp.inc.php on line 26
The class at line 26 of smtp.inc.php is
class SMTP {
var $SMTP_PORT = 25; # the default SMTP PORT
var $CRLF = "\r\n"; # CRLF pair
var $smtp_conn; # the socket to the server
var $error; # error if any on the last call
var $helo_rply; # the reply the server sent to us for HELO
var $do_debug; # the level of debug to perform
The problem is this line:
Change it to this: