php - 连接失败。错误 #2 : stream_socket_enable_crypto(): Peer certificate with PHPMailer

标签 php email

我正在使用以下代码发送邮件。它在 gmail 服务器中运行良好,但不适用于我的域。
它显示了一个错误,如

Connection failed. Error #2: stream_socket_enable_crypto(): Peer certificate CN=`*.999servers.com'



我该如何解决这个问题?
到目前为止,这是我的代码:
require("PHPMailer/src/PHPMailer.php");
require("PHPMailer/src/SMTP.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 4;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "mail.mydomain.in";
$mail->Port = 587;
$mail->IsHTML(true);
$mail->Username = "mail";
$mail->Password = "password";

$mail->SetFrom($admin_user_mail);
$mail->AddAddress($login_user_mail);
$mail->AddCC($admin_user_mail);
$mail->Subject = "Mail Subject";
$mail->Body = "Mail Content";


if($mail->send()) 
{   
    echo "Mail Send";
} else 
{
    echo "Mail Not sent";
}

最佳答案

$mail->SMTPOptions = array(
       'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
            )
        );    

关于php - 连接失败。错误 #2 : stream_socket_enable_crypto(): Peer certificate with PHPMailer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52765525/

相关文章:

email - 群发电子邮件跟踪

ios - 在 Parse 中更新用户电子邮件

javascript onsubmit 事件用于多个功能检查不起作用

email - Cron 发送电子邮件时使用 STDERR 但不使用 STDOUT?

php - MySqL只过滤一个id

PHP 7.1.7 imagecreatetruecolor 产生 500 错误

php - MySQL建表错误?也许是版本问题?

iphone - MFMailComposeViewController 电子邮件地址无效?

php - 在 PHP 中重定向回上一页

php - 使用 Foreach 用数组更新 MySQL 表