Here my php code to send email with phpmailer via YANDEX MAIL:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include_once "phpmailer/PHPMailer.php";
include_once "phpmailer/Exception.php";
include_once "phpmailer/SMTP.php";
Main content
if (isset($_POST['submit'])) {
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$mail = new PHPMailer();
//if we want to send via SMTP
$mail->Host = 'smtp.yandex.ru';
//$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Username = "example@yandex.ru";//my yandex mail
$mail->Password = "password";//my yandex password
$mail->SMTPSecure = "ssl"; //TLS
$mail->Port = 465; //587
$mail->CharSet = "UTF-8";
$mail->addAddress('example@gmail.com'); //to
$mail->setFrom($email);
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $message;
if ($mail->send())
echo "Your email has been sent, thank you!";
else
echo "Please try again!".$mail->ErrorInfo;
}
?>
It shows "Your email has been sent, thank you!" but not send anything. How to solve it?