Answer the question
In order to leave comments, you need to log in
Why is mail not sent via PHPMailer?
This is what the send email function looks like:
function send_message($array) {
global $alias;
global $settings;
$message = "
<p>" . $settings["mail"]["message"] . "</p>
<br>
<p><strong>Дата обращения: </strong>" . date('d.m.Y H:i:s') . "</p>
";
foreach($array as $field) {
$name = $field["name"];
$value = $field["value"];
if ($name !== "g-recaptcha-response" && $name !== "agreement") {
$message .= "<p><strong>" . $alias[$name] . ":</strong> " . $value . "</p>";
}
};
$message .= "<br><br><p>Это письмо сгенерировано автоматически. Пожалуйста, не отвечайте на него.</p>";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.yandex.ru';
$mail->SMTPAuth = true;
$mail->Username = $settings["mail"]["auth"]["username"];
$mail->Password = $settings["mail"]["auth"]["password"];
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->CharSet = "UTF-8";
$mail->Subject = $settings["mail"]["subject"];
$mail->SetFrom($settings["mail"]["sender"]["address"], $settings["mail"]["sender"]["alias"]);
$mail->MsgHTML($message);
$mail->AddAddress($settings["mail"]["receiver"]["address"], $settings["mail"]["receiver"]["alias"]);
$mail->Send();
};
Answer the question
In order to leave comments, you need to log in
Try mail_port = 587. Change SMPT from Yandex to some other one. Disable your antivirus. All these steps at different times helped me in one way or another.
By the way, do you get a send error message?
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question