Konfigurieren von gmail smtp und phpmailer?

Ich will wissen, wo das problem ist weil ich bekomme die Authentifizierung Fehler.

  1. Ich hab schon ein paar gmail-Konten,
  2. Erstellte ich eine neue für meine website,
  3. Ich habe eine neue E-Mail in "- Konto und importieren", um mein altes gmail-Konto.
  4. Kopierte ich meine neue E-Mail-Benutzernamen und Passwort ein, um phpmailer code
include_once('phpmailer/class.phpmailer.php');
include_once('phpmailer/class.smtp.php');
//6nb5Drv;
function sendmail(){
$mail = new PHPMailer();  

$mail->IsSMTP();                                      //set mailer to use SMTP
$mail->SMTPAuth = true;     //turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";  //specify main and backup server
$mail->Port = 587; //Set the SMTP port i tried and 457
$mail->Username = '[email protected]';                //SMTP username
$mail->Password = 'newmailpass';                  //SMTP password

$mail->SMTPDebug  = 1;                     //enables SMTP debug information (for testing)
                                           //1 = errors and messages
                                           //2 = messages only

$mail->From = '[email protected]';
$mail->FromName = 'From';
$mail->AddAddress('[email protected]', 'To');  //Add a recipient

$mail->IsHTML(true);                                  //Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <strong>in bold!</strong>';
$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;
   exit;
}

echo 'Message has been sent';
}
sendmail();

Aber ich erhalte einen Authentifizierungsfehler.
Was ist falsch?
Wahrscheinlich ist etwas mit den Anmeldeinformationen, wie Konfiguriere ich die gmail-smtp?

Debug-Bericht:

2015-12-04 17:56:15-CLIENT -> SERVER: EHLO www.site.co
2015-12-04 17:56:15-CLIENT -> SERVER: STARTTLS 2015-12-04
17:56:15-CLIENT -> SERVER: EHLO www.site.co 2015-12-04
17:56:15-CLIENT -> SERVER: AUTH LOGIN 2015-12-04 17:56:15-CLIENT ->
SERVER: UHJlZGljdG9sb2d5 2015-12-04 17:56:15-CLIENT -> SERVER:
U2dHZlB0VHZUbTZ1SW9ZMi1qTlNCQQ== 2015-12-04 17:56:17 SMTP-FEHLER:
Passwort-Befehl ist fehlgeschlagen: 435 4.7.8 Schalter-Fehler: Authentifizierung fehlgeschlagen:
UGFzc3dvcmQ6 2015-12-04 17:56:17 SMTP-Fehler: Konnte nicht authentifizieren.
2015-12-04 17:56:17 CLIENT -> SERVER: QUIT 2015-12-04 17:56:17 SMTP
connect() ist fehlgeschlagen.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Nachricht
konnte nicht gesendet werden.Mailer Error: SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

  • Basis-code in die gmail-Beispiel mit PHPMailer, nicht einige alte und veraltete Kopie. Verwenden Sie den Autoloader. Lesen Sie die Dokumentation.
  • Wenn Sie SMTPDebug = 2 (und ignorieren Sie die falsche Beschreibung im code), werden Sie sehen, warum Google Mail ist die Ablehnung Ihrer Anmeldung.
InformationsquelleAutor DocNet | 2015-12-04
Schreibe einen Kommentar