Cześć wszystkim. Zainstalowałem PHPMailer'a poprzez cmd tak jak napisali na stronie: https://github.com/PHPMailer/PHPMailer
Po czym przekleiłem sobie ich kod z example i spróbowałem to odpalić.
~Podczas tej próby pola były wypełnione prawidłowymi danymi (account, password etc.)
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'mail@gmail.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
//Recipients
$mail->setFrom('mail@gmail.com', 'MDG');
$mail->addAddress('mail@gmail.com', 'MT');
//Content
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
i na końcu wyskakują mi takie oto cuda:
2017-12-04 15:56:06 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP g82sm2923128ljg.57 - gsmtp
2017-12-04 15:56:06 CLIENT -> SERVER: EHLO localhost
2017-12-04 15:56:06 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a02:a318:c140:ed80:85cc:6882:e71e:c063]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-12-04 15:56:06 CLIENT -> SERVER: STARTTLS
2017-12-04 15:56:06 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2017-12-04 15:56:06 CLIENT -> SERVER: EHLO localhost
2017-12-04 15:56:06 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a02:a318:c140:ed80:85cc:6882:e71e:c063]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2017-12-04 15:56:06 CLIENT -> SERVER: AUTH LOGIN
2017-12-04 15:56:06 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-12-04 15:56:06 CLIENT -> SERVER: <credentials hidden>
2017-12-04 15:56:06 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-12-04 15:56:06 CLIENT -> SERVER: <credentials hidden>
2017-12-04 15:56:06 SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbva534-5.7.14 TI3x5OWgzx0rGwwiNUvOPz9Zm2FaqsXePMDiNuIqADCzg0Ux0xW1ENr2LOlC4sOwR0Cug-534-5.7.14 0buAygq6zqCZqReDuYjDLrDLKyLWfhNBMxxaRdgl-KOA5iIwh0bEcEaeFcW5uZTRKGzSjY534-5.7.14 Y-EdLNvxbp4GOHS334r5QGBYHKl5g96EdhCxzyqd_B760ry8D8XNFoKbiMa4SUIPhJQqCq534-5.7.14 e0d281SymjxMiLR9IEwd5A6s4rhq8> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 g82sm2923128ljg.57 - gsmtp
2017-12-04 15:56:06 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbva534-5.7.14 TI3x5OWgzx0rGwwiNUvOPz9Zm2FaqsXePMDiNuIqADCzg0Ux0xW1ENr2LOlC4sOwR0Cug-534-5.7.14 0buAygq6zqCZqReDuYjDLrDLKyLWfhNBMxxaRdgl-KOA5iIwh0bEcEaeFcW5uZTRKGzSjY534-5.7.14 Y-EdLNvxbp4GOHS334r5QGBYHKl5g96EdhCxzyqd_B760ry8D8XNFoKbiMa4SUIPhJQqCq534-5.7.14 e0d281SymjxMiLR9IEwd5A6s4rhq8> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 g82sm2923128ljg.57 - gsmtp
SMTP Error: Could not authenticate.
2017-12-04 15:56:06 CLIENT -> SERVER: QUIT
2017-12-04 15:56:06 SERVER -> CLIENT: 221 2.0.0 closing connection g82sm2923128ljg.57 - gsmtp
SMTP Error: Could not authenticate.
Message could not be sent.Mailer Error: SMTP Error: Could not authenticate.
Jestem zalogowany na konto, z którego chcę tego mail'a wysłać, próbuję różnych rzeczy z internetu jednak nie mogę się z tym uporać.
Mógłby ktoś się wypowiedzieć?