2011-01-11 16 views
1

Ich versuche, PHP-Mailer zu arbeiten. Ich bekomme einen Fehler, konnte aber keine Informationen von Google finden.PHP, PHPMailer: Beispielcode für PHPMailer kann nicht funktionieren

$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 

Der obige Code ist, was ich verwende, aber wenn ich versuche, es mir folgend in meinem Browser bekommen zu laufen ...

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

Hier ist die Linie, um es sich bezieht ...

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

Wenn jemand helfen kann, würde es sehr geschätzt werden! Vielen Dank.

+1

Haben Sie '$ this-> Encoding' überprüft? Ich glaube nicht, dass "Encoding" eine Variable ist. – Ben

Antwort

6

Encoding ist keine Variable: $this->Encoding

+2

Crazy, nun, ich habe es von ihrer Website heruntergeladen, ich denke, sie haben versagt, weil ich diese Datei nicht bearbeitet habe. Danke für die Hilfe. – daveomcd

2

Sind Sie sicher, dass Sie $this->$Encoding möchten? Ich denke du willst $this->Encoding (beachte das Fehlen von $ on Encoding).

+1

Danke für die Hilfe habe ich nicht bemerkt und ich hatte ihre Datei nicht bearbeitet, also habe ich es nicht wirklich überprüft. Definitiv etwas gelernt heute :) – daveomcd

4

Es gibt einen Fehler in Zeile 271 in der Datei phpmailer.inc.php

Die Linie ist:

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

ändern es für:

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