Full code below. If i change verify_peer to true it will return SMTP ERROR: Failed to connect to server: (0). But SSL have been installed already. You can check it here How to solve this? i dont want to skip verifying peer. Server nginx. (CLOUDFLARE SSL)
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.mail.ru";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "somemail@mail.ru"; // SMTP account username example
$mail->Password = "somepass"; // SMTP account password example
$mail->SetFrom("somemail@mail.ru");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("somemail2@mail.ru");
$mail->SMTPOptions = array (
'ssl' => array (
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
The solution is change the autosigned SSL Certificate to support SNI. You would have to ask to your hosting provider about that.
Regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.