Я пытаюсь отправить электронную почту, используя PHPMalier. но это показывает мне ошибки. и я уверен, что мой E-mail и мой пароль верны. Я пробовал каждое решение на Youtube, Google и даже в StackOverflow, но мне ничего не помогло. PHP для меня немного новый, поэтому я не очень хорошо знаю PHP.
вот главная ошибка
SMTP ERROR: Password command failed:
Please log in via your web browser
SMTP Error: Could not authenticate.
2018-05-16 13:11:10 CLIENT -> SERVER: QUIT
2018-05-16 13:11:10 SERVER -> CLIENT: 221 2.0.0 closing connection i1-
v6sm5130251pfi.133 - gsmtp
SMTP Error: Could not authenticate.
Email Error.INFO:SMTP Error: Could not authenticate.
А вот и мой код
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
require "vendor/autoload.php";
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
$developmentMode = true;
$mailer = new PHPMailer($developmentMode);
try {
$mailer->SMTPDebug = 2;
$mailer->isSTMP();
if ($developmentMode) {
$mailer->SMTPOptions = [
'ssl'=> [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
}
$mailer->Host = 'smtp.gmail.com';
$mailer->SMTPAuth = true;
$mailer->Username = "mygmail@gmail.com";
$mailer->Password = "password";
$mailer->SMTPSecure = 'tls';
$mailer->Port = 587;
$mailer-> setFrom("mygmail@gmail.com", "Izaya");
$mailer->addAddress("anothergmail@gmail.com","orihara");
$mailer->isHTML(true);
$mailer->Subject = "Hey There";
$mailer->Body = "NICE TO MEET YOU IZAYA ";
$mailer->send();
$mailer->ClearAllRecipients();
echo "Mail has been Sent";
}catch (Exception $e) {
echo "Email Error.INFO:" . $mailer->ErrorInfo;
}
?>
</body>
</html>