Answer the question
In order to leave comments, you need to log in
How to connect to Yandex SMTP?
Hello! I can't send mail via PHPMailer, yesterday I spent the whole day on this question.
Maybe I'm missing some small thing. I will be grateful for any help.
What I've done:
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->isSMTP(); // Send using SMTP
$mail->Host = 'smtp.yandex.ru'; // Set the SMTP server to send through
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'логин аккаунта без @yandex.ru'; // SMTP username
$mail->Password = 'пароль аккаунта'; // SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 465; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
2020-05-25 15:29:38 SMTP ERROR: Failed to connect to server: (0)
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
или
2020-05-25 15:39:14 SERVER -> CLIENT:
2020-05-25 15:39:14 SMTP NOTICE: EOF caught while checking if connected
SMTP Error: Could not connect to SMTP host.
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
Answer the question
In order to leave comments, you need to log in
Technical support solved the issue in 2 approaches. Here it is in short.
When analyzing the problem, we found that the server had outdated root certificates, as a result of which the SSL connection to Yandex mail servers ended with an error, for example:
[[email protected] /]# echo | openssl s_client -servername smtp.yandex.ru -connect smtp.yandex.ru:465 2>&1 | grep 'Verify return code'
Verify return code: 20 (unable to get local issuer certificate)
[[email protected] /]#
Added the Yandex root certificate to the list of trusted certificates on the server. Now we do not see any problems with a secure connection to their mail servers:
[[email protected] /]# echo | openssl s_client -servername smtp.yandex.ru -connect smtp.yandex.ru:465 2>&1 | grep 'Verify return code'
Verify return code: 0 (ok)
[[email protected] /]#
We made additional settings for root certificates and specified a host for connection in the SMTP script.
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->isSMTP();
$mail->Host = 'smtp.yandex.ru';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'пароль от ящика [email protected]';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = 465;
var_dump(fsockopen("ssl://smtp.yandex.ru",465));
результат
resource(2) of type (stream)
если подключения нет пишет
bool(false)
The most banal - did you go to your mailbox through Yandex.Mail? Has it been confirmed?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question