2017-09-15 5 views
0

Ich habe versucht, eine Mail mit PHP-Mailer auf Xampp zu senden, und ich bekomme diese Fehlermeldung Nachricht konnte nicht gesendet werden. Mailer Error: Die folgende Absenderadresse ist fehlgeschlagen: [email protected]: Called Mail() ohne Verbindungwie man Post sendet mit phpmailer auf xampp

bitte, ich brauche Hilfe, wie Sie das beheben können. Hier ist mein Code;

<?php 
require('class.phpmailer.php'); 

    $mail = new PHPMailer; 
    $mail->IsSMTP(); 
    $mail->SMTPAuth = true; 
    $mail->Host = "tls://smtp.gmail.com"; 
    $mail->Port = 25; 
    $mail->Username = "[email protected]"; 
    $mail->Password = "xxxxx"; 
    //Sending the actual email 
    $mail->setFrom('[email protected]', 'Aaron'); 
    $mail->addAddress('[email protected]', 'Aaron');  // Add a recipient 
    $mail->isHTML(false);         // Set email format to HTML 
    $mail->Subject = 'Calculation form results from '; 
    $mail->Body = 'testing...'; 

    if(!$mail->send()) { 
    echo 'Message could not be sent. '; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
    exit; 
    } 
?> 
+1

Nach dem Tutorial von phpmailer sollten Sie 'require 'PHPMailerAutoload.php' verwenden;'. Es sollte auch '$ mail = new PHPMailer();' sein. https://github.com/PHPMailer/PHPMailer/wiki/Tutorial – IcedAnt

+0

https://support.google.com/mail/answer/7104828?hl=de&visit_id=1-636410671215867907-2344642736&rd=3 Ihr Port ist falsch. Versuchen Sie 587 für TLS. – IcedAnt

+0

'$ mail-> Host =" tls: //smtp.gmail.com "; $ mail-> Port = 587; 'immer noch der gleiche Fehler –

Antwort

1

Wörtlich kopiert von https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps

//Create a new PHPMailer instance 
$mail = new PHPMailer; 

//Tell PHPMailer to use SMTP 
$mail->isSMTP(); 

//Set the hostname of the mail server 
$mail->Host = 'smtp.gmail.com'; 
// use 
// $mail->Host = gethostbyname('smtp.gmail.com'); 
// if your network does not support SMTP over IPv6 

//Set the SMTP port number - 587 for authenticated TLS 
$mail->Port = 587; 

//Set the encryption system to use - ssl (deprecated) or tls 
$mail->SMTPSecure = 'tls'; 

//Whether to use SMTP authentication 
$mail->SMTPAuth = true; 

//Username to use for SMTP authentication - use full email address for gmail 
$mail->Username = "[email protected]"; 

//Password to use for SMTP authentication 
$mail->Password = "yourpassword"; 

//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'First Last'); 

//Set an alternative reply-to address 
$mail->addReplyTo('[email protected]', 'First Last'); 

//Set who the message is to be sent to 
$mail->addAddress('[email protected]', 'John Doe'); 
+0

vielen Dank! –

+0

Wenn es funktioniert, können Sie es als die richtige Antwort akzeptieren? – IcedAnt

+0

Oo, gerade hat ... –