Answer the question
In order to leave comments, you need to log in
SMTP PHP yandex.ru The password was not accepted by the server as correct! How to fix?
I'm trying to build a script to send emails.
part of the script....
fputs($socket, base64_encode($config['smtp_username']) . "\r\n");
if (!server_parse($socket, "334", __LINE__)) {
if ($config['smtp_debug']) echo '<p>Логин авторизации не был принят сервером!</p>';
fclose($socket);
return false;
}
fputs($socket,base64_encode($config['smtp_password']). "\r\n");
if (!server_parse($socket, "235", __LINE__)) {
if ($config['smtp_debug']) echo '<p>Пароль не был принят сервером как верный! Ошибка авторизации!</p>';
fclose($socket);
return false;
}
fputs($socket, "MAIL FROM: <".$config['smtp_username'].">\r\n");
if (!server_parse($socket, "250", __LINE__)) {
if ($config['smtp_debug']) echo '<p>Не могу отправить комманду MAIL FROM: </p>';
fclose($socket);
return false;
}
.......
function server_parse($socket, $response, $line = __LINE__) {
global $config;
while (@substr($server_response, 3, 1) != ' ') {
if (!($server_response = fgets($socket, 256))) {
if ($config['smtp_debug']) echo "<p>Проблемы с отправкой почты!</p>$response<br>$line<br>";
return false;
}
}
if (!(substr($server_response, 0, 3) == $response)) {
if ($config['smtp_debug']) echo "<p>Проблемы с отправкой почты!</p>$response<br>$line<br>";
return false;
}
return true;
}
Answer the question
In order to leave comments, you need to log in
Try turning off app passwords in your profile settings. I had a similar problem: no imap/smtp client connected.
Perhaps yandex blocked login attempts. They do this sometimes, forcing them to bind a phone number. You need to go through the web and confirm, a confirmation code will come to your phone.
I don’t specifically remember the link (it came in my smpt server response, something like ya.cc/blablabla ).
Well, or the second option is to try using another mailbox that definitely works in the mail client.
Naturally, this is not the only variant of your problem.
Also try just a script:
<?php
require_once ( '/usr/share/php/libphp-phpmailer/autoload.php' ); // Убедитесь в этом пути.
//$mail = new PHPMailer;
$mail = new PHPMailer\PHPMailer\PHPMailer();
//Enable SMTP debugging.
$mail->SMTPDebug = 3;
//Set PHPMailer to use SMTP.
$mail->isSMTP();
//Set SMTP host name
$mail->Host = "smtp.yandex.ru";
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "ВАШ_ЯЩИК";
$mail->Password = "ВАШ_ПАРОЛЬ";
$mail->SMTPSecure = "ssl";
//Set TCP port to connect to
$mail->Port = 465;
$mail->From = "ВАШ_ЯЩИК";
$mail->FromName = "пофигу_что_тут";
$mail->addAddress("ЯЩИК_АДРЕСАТА");
$mail->isHTML(true);
$mail->Subject = "Test MAIL 1";
$mail->Body = "<i>from сonsole</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
It's easier to persuade Google mail to accept mail directly (it's enough to put a guard that non-secure logins are allowed) than mailra with Yandex.
For them, you will also have to configure SPF and DKIM.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question