Answer the question
In order to leave comments, you need to log in
Why doesn't sending mail from PHPMailer using smtp.yandex work?
Good afternoon,
I’m trying to send myself a test message using the yandex SMTP server, I sketched out such an example, but as a result of the letter I still don’t receive any errors during its execution.
there are two php.ini configs on the server:
/etc/php/7.3/apache2/php.ini
/etc/php/7.3/cli/php.ini
SMTP = smtp.yandex.ru
smtp_port = 465
composer require phpmailer/phpmailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mailToAddr = '[email protected]';
$subject = 'test';
$message = 'message';
try {
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.yandex.ru'; // Specify main and backup server
$mail->Port = 465; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'nerabotayouposng'; // SMTP passwora
$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted
$mail->From = '[email protected]';
$mail->FromName = 'TEST';
$mail->AddAddress($mailToAddr, 'test');
$mail->Subject = $subject;
$mail->Body = $message;
$mail->Send()
} catch(phpmailerException $e) {
echo $e->errorMessage();
}
?>
Nov 7 13:39:01 vm274093 CRON[22718]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Nov 7 13:39:01 vm274093 systemd[1]: Starting Clean php session files...
Nov 7 13:39:01 vm274093 systemd[1]: phpsessionclean.service: Succeeded.
Nov 7 13:39:01 vm274093 systemd[1]: Started Clean php session files.
Nov 7 13:40:01 vm274093 CRON[22922]: (smmsp) CMD (test -x /etc/init.d/sendmail && test -x /usr/share/sendmail/sendmail && test -x /usr/lib/sm.bin/sendmail && /usr/share/sendmail/sendmail cron-msp)
Answer the question
In order to leave comments, you need to log in
because the spammers got everyone and now setting up a mailing list is not just a few lines in PHP.
SPF, DKIM and DMARC - read what it is.
well, most mailers do not like plain authorization
You have the same sender and recipient address, so maybe that's why he doesn't want to send to himself. Otherwise, the SMTP server should return an error.
Using Yandex is not the best idea; setting up your own server is not so difficult. If you fit into the limits , then for now you can use it.
$mail->SMTPDebug = 3; and watch what is happening, all that is written here is poking a finger into the sky. Why no one said that it is necessary to understand what the problem is, instead of putting forward strange unreasonable assumptions, is a mystery.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question