Я использую PHPMailer для отправки почты по SMTP, он отлично работает с моей личной учетной записью, но когда я использую учетную запись gsuite gmail, это выдает мне ошибку.
2019-04-11 05:21:54 SERVER -> CLIENT: 220 smtp-relay.gmail.com ESMTP 11sm586472itw.3 - gsmtp<br>
2019-04-11 05:21:54 CLIENT -> SERVER: EHLO 172.16.17.54<br>
2019-04-11 05:21:54 SERVER -> CLIENT: 250-smtp-relay.gmail.com at your service, [202.131.125.99]250-SIZE 157286400250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8<br>
2019-04-11 05:21:54 CLIENT -> SERVER: AUTH LOGIN<br>
2019-04-11 05:21:55 SERVER -> CLIENT: 334 VXNlcm5hbWU6<br>
2019-04-11 05:21:55 CLIENT -> SERVER: <credentials hidden><br>
2019-04-11 05:21:55 SERVER -> CLIENT: 334 UGFzc3dvcmQ6<br>
2019-04-11 05:21:55 CLIENT -> SERVER: <credentials hidden><br>
2019-04-11 05:21:55 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials 11sm586472itw.3 - gsmtp<br>
2019-04-11 05:21:55 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials 11sm586472itw.3 - gsmtp<br>
SMTP Error: Could not authenticate.<br>
2019-04-11 05:21:55 CLIENT -> SERVER: QUIT<br>
2019-04-11 05:21:56 SERVER -> CLIENT: 221 2.0.0 closing connection 11sm586472itw.3 - gsmtp<br>
SMTP Error: Could not authenticate.<br>
Вот настройка SMTP
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->addCustomHeader('MIME-Version: 1.0');
$mail->addCustomHeader('Content-Type: text/html; charset=utf-8');
$mail->Host = 'smtp-relay.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '****@domain.com'; // SMTP username
$mail->Password = '****'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to