无法通过 Gmail 服务器通过 PHP 邮件程序发送邮件



我遇到了一个问题,我无法通过我的gmail服务器使用我的phpmailer()发送邮件。我能知道问题出在哪里吗?

这是我的phpmailer代码:

    if($count){
    echo "<p>New user record has been successfully inserted.</p>n";
    require_once("PHPMailer-master/class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls'; 
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 587;
    $mail->IsHTML(true);
    $mail->Username = "";
    $mail->Password = "";
    $mail->SetFrom("testnoreply@gmail.com", 'Gold Fish');
    $mail->Subject = "Registration Successful";
    $mail->Body = "Welcome to Gold Hotel Event. Your registration have been received. It still processing now! Thank you.";
    $mail->AddAddress($userEmail);
    if (!$mail->Send()) {
        echo "Mailer Error: " .$mail->ErrorInfo;
    } else {
        echo "Mail has been sent";
        echo "<br>";
        echo "<br>";
    }
} else {
    echo "<p>Insertion failed.</p>n";
}

我也遇到了这个问题:

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in

您是否取消注释了php.ini文件中extension=php_openssl.dll行。Gmail使用openssl,php文件需要识别它。

相关内容

最新更新