R
R
RS-qrsk2021-07-07 23:04:19
PHP
RS-qrsk, 2021-07-07 23:04:19

PHPMailer does not send mail to yandex, what's wrong?

PHPMailer does not send mail via SMTP yandex, the debugger gives the following:

could not authenticate.


So, by mail:
All data is entered correctly, the application password is created, all mailers are enabled, mail is active
Server:
openssl - enabled, certificate hangs

Sending process
$username = '***********@yandex.ru';
$password = '******';

$host = 'smtp.yandex.ru';  // Пробовал 'ssl://smtp.yandex.ru'
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; 
$mail->Port = 465;

$mail->CharSet = 'UTF-8';
$mail->setFrom($username, '*****');
$mail->addAddress($user_email);  // $user_email = '******@yandex.ru'

$mail->isHTML(true); 
$mail->Subject = 'Тест';
$mail->Body = '<b>123</b>';
$mail->AltBody = 'Тестовое сообщение.';
$mail->send();


What could be wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RS-qrsk, 2021-07-14
@RS-qrsk

In general, who cares, the problem eventually turned out to be in the hosting, they tested it on another one and it all worked. Unfortunately, the owner of the old hosting did not want to make changes.
If you run into a similar problem and you're sure your code is correct, check with OpenSSL, it will show you exactly what the problem is. In my case, the problem is with certificates.

A
Alexey, 2021-07-07
@alexeyshi

Try to enable imap in your mail settings (for greater certainty, you can check the box for POP3) Yasha also
60e614fdab74e563987077.jpeg
has passwords for applications, you can try to log in using the generated application password.
60e61748b8d0e339577726.jpeg
And you can also try to replace ENCRYPTION_SMTPS with ENCRYPTION_STARTTLS and port from 465 to 587

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question