Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]PHPmailer
Forum PHP.pl > Forum > Przedszkole
mikarosek5
Witam mam problem z wysłaniem maila za pomocna PHPmailer'a.
Pobrałem skrypt z githuba i nie moge sobie poradzic z wysyłaniem.
Skrypt uruchamiam na xampp'ie.
Na Gmailu włączyłem dostęp dla mniej bezpiecznych aplikacji a ciągle nie moge wysyłac wiadomosci.
Na 100% dobrze wpisuje email i hasło wiec nie wiem gdzie moze lezec problem prosze o pomoc.
Ponizej zamieszczam "mój" skrypt oraz informacje z wyświetlane za pomoca debbugera.
  1. <?php
  2. require '../mail/PHPMailerAutoload.php';
  3. require("../mail/class.smtp.php");
  4.  
  5. $mail = new PHPMailer;
  6.  
  7. //$mail->SMTPDebug = 3; // Enable verbose debug output
  8.  
  9. $mail->isSMTP(); // Set mailer to use SMTP
  10. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  11. $mail->SMTPAuth = true; // Enable SMTP authentication
  12. $mail->Username = 'mojemail@gmail.com'; // SMTP username
  13. $mail->Password = 'mojehasłogmail'; // SMTP password
  14. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  15. $mail->Port = 587; // TCP port to connect to
  16.  
  17. $mail->setFrom('uwolnic_orke@onet.pl', 'Mailer');
  18. $mail->addAddress('uwolnic_orke@onet.pl', 'Joe User'); // Add a recipient
  19. //$mail->addAddress('uwolnic_orke@onet.pl'); // Name is optional
  20. $mail->addReplyTo('info@example.com', 'Information');
  21. $mail->addCC('cc@example.com');
  22. //$mail->addBCC('bcc@example.com');
  23.  
  24. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  25. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  26. $mail->isHTML(true); // Set email format to HTML
  27.  
  28. $mail->Subject = 'Here is the subject';
  29. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  30. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  31.  
  32. if(!$mail->send()) {
  33. echo 'Message could not be sent.';
  34. echo 'Mailer Error: ' . $mail->ErrorInfo;
  35. } else {
  36. echo 'Message has been sent';
  37. }

https://support.google.com/mail/?p=WantAuthError f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 SMTP ERROR: STARTTLS command failed: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 SMTP Error: Could not connect to SMTP host. 2016-12-14 18:56:19 CLIENT -> SERVER: QUIT 2016-12-14 18:56:19 SERVER -> CLIENT: 221 2.0.0 closing connection f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 Connection: closed 2016-12-14 18:56:19 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting">2016-12-14 18:56:19 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( ) 2016-12-14 18:56:19 Connection: opened 2016-12-14 18:56:19 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 CLIENT -> SERVER: EHLO localhost 2016-12-14 18:56:19 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [83.26.232.44] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 2016-12-14 18:56:19 CLIENT -> SERVER: STARTTLS 2016-12-14 18:56:19 SERVER -> CLIENT: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 SMTP ERROR: STARTTLS command failed: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 SMTP Error: Could not connect to SMTP host. 2016-12-14 18:56:19 CLIENT -> SERVER: QUIT 2016-12-14 18:56:19 SERVER -> CLIENT: 221 2.0.0 closing connection f134sm8875548wmf.19 - gsmtp 2016-12-14 18:56:19 Connection: closed 2016-12-14 18:56:19 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Tomplus
Sprawdzałeś czy konto google z którego się łączysz nadal jest dostępne? Bo brak poprawnej połączenia z SMTP to efekt tego że Google nie pozwala przesłać wiadomości.


viking
Tak się zastanawiam. SetFrom nie powinien być taki sam jak konto? Nie pamiętam czy gmail coś takiego przepuszczał. Ale tak czy inaczej nie w tym rzecz Connection: opening to ssl://smtp.gmail.com:465 wyraźnie sugeruje coś innego niż masz w konfigu.
vokiel
Sprawdzałeś na porcie 465?

Poza tym włącz sobie w PHPMailer pełny log to będzie więcej szczegółów.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.