2016-08-03 16 views
-1

Ich versuche, eine E-Mail mit PHP Mailer SMTP zu senden, aber auch nachdem ich auf dem SMTPDebug nichts drehen gezeigt und ich nur falsch, wenn $ mail-> send(),PHP_Mailer druckt keine Informationen debuggen

das ist, was ich habe

$Mail = new PHPMailer();   
$Mail->SMTPDebug = 2; 
$Mail->IsSMTP(); 
$Mail->SMTPAuth = true; 
$Mail->Host = "smtp.gmail.com"; 
$Mail->SMTPSecure = "tls"; 
$Mail->Port = 587; 
$Mail->Priority = 1; 
$Mail->CharSet = 'UTF-8'; 
$Mail->Username = '[email protected]'; 
$Mail->Password = 'xxxxxxxxxxxxxxxxxx'; 
$Mail->Encoding = '8bit'; 
$Mail->Subject = $subject; 
$Mail->ContentType = 'text/html; charset=utf-8\r\n'; 
$Mail->From = "[email protected]"; 
$Mail->FromName = "XXXXXXXXXXXXXXXXX"; 
$Mail->AddReplyTo($replyToEmail, $replyToName); 
$Mail->WordWrap = 998; // RFC 2822 Compliant for Max 998 characters per line 
$Mail->IsHTML(true);  
$Mail->body=$tpl; 
$Mail->AddAddress($email); 
$Mail->Send(); <------ false and doesn't print out why 

ich nicht die Debug-Informationen zu zeigen, bis bekommen, weiß jemand, warum?

Dank

+0

Prüfen Sie, ob die PHP-Fehlerberichterstattung etwas ergibt http://php.net/manual/en/function.error-reporting.php –

+0

'$ mail-> Priority = 1 ; Normal, 5 = niedrig) 'Wenn das Ihr richtiger Code ist, sollten Sie einen Parse-Fehler für diesen und aus ein paar Gründen bekommen haben. Wurden diese Kommentare überhaupt gelesen? –

+0

das war ein Kommentar, den ich gelöscht habe, wenn ich die Frage –

Antwort

0

Probieren catch

try { 
$Mail = new PHPMailer(true); //<-- edit add true here   
$Mail->SMTPDebug = 2; 
$Mail->IsSMTP(); 
$Mail->SMTPAuth = true; 
$Mail->Host = "smtp.gmail.com"; 
$Mail->SMTPSecure = "tls"; 
$Mail->Port = 587; 
$Mail->Priority = 1; //Normal, 5 = low) 
$Mail->CharSet = 'UTF-8'; 
$Mail->Username = '[email protected]'; 
$Mail->Password = 'xxxxxxxxxxxxxxxxxx'; 
$Mail->Encoding = '8bit'; 
$Mail->Subject = $subject; 
$Mail->ContentType = 'text/html; charset=utf-8\r\n'; 
$Mail->From = "[email protected]"; 
$Mail->FromName = "XXXXXXXXXXXXXXXXX"; 
$Mail->AddReplyTo($replyToEmail, $replyToName); 
$Mail->WordWrap = 998; // RFC 2822 Compliant for Max 998 characters per line 
$Mail->IsHTML(true);  
$Mail->body=$tpl; 
$Mail->AddAddress($email); 
$Mail->Send(); //<------ false and doesn't print out why 
} catch (phpmailerException $e) { 
    echo $e->errorMessage(); //Error from PHPMailer 
} catch (Exception $e) { 
    echo $e->getMessage(); //Other error messages 
} 
+0

danke, aber keine Ausnahme wird ausgelöst –

+1

PHPMailer löst keine Ausnahmen, es sei denn, Sie sagen es - übergeben Sie 'true' an den Konstruktor. – Synchro

+0

true ich didnt C/C gut – MaximeK

1

Sie verwenden eine unmodifizierte Version von PHPMailer Unter der Annahme, dann den falschen Fall einige Ihrer Eigenschaft/Methode Nutzungen verwenden. Vom PHPMailer einfachen Beispiel erhältlich bei https://github.com/PHPMailer/PHPMailer:

require 'PHPMailerAutoload.php'; 

$mail = new PHPMailer; 

//$mail->SMTPDebug = 3;        // Enable verbose debug output 

$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true;        // Enable SMTP authentication 
$mail->Username = '[email protected]';     // SMTP username 
$mail->Password = 'secret';       // SMTP password 
$mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
$mail->Port = 587;         // TCP port to connect to 

$mail->setFrom('[email protected]', 'Mailer'); 
$mail->addAddress('[email protected]', 'Joe User');  // Add a recipient 
$mail->addAddress('[email protected]');    // Name is optional 
$mail->addReplyTo('[email protected]', 'Information'); 
$mail->addCC('[email protected]'); 
$mail->addBCC('[email protected]'); 

$mail->addAttachment('/var/tmp/file.tar.gz');   // Add attachments 
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name 
$mail->isHTML(true);         // Set email format to HTML 

$mail->Subject = 'Here is the subject'; 
$mail->Body = 'This is the HTML message body <b>in bold!</b>'; 
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 

if(!$mail->send()) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} else { 
    echo 'Message has been sent'; 
} 
+0

Vielen Dank Daniell, für die richtige Sache, wenn Sie neu hier sind :) – Synchro

+0

Ich versuche nur, hilfsbereit zu sein. Ich habe im Laufe der Jahre genug über SO gelauert, es schien lange überfällig zu sein, zu versuchen, jemandem zu helfen. Ich denke, dass die Groß-/Kleinschreibung nicht das Problem ist. – Daniell

Verwandte Themen