Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法通过Gmail服务器通过PHP邮件发送邮件_Php_Email - Fatal编程技术网

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

无法通过Gmail服务器通过PHP邮件发送邮件,php,email,Php,Email,我遇到了一个问题,无法通过gmail服务器使用phpMail()发送邮件。我能知道有什么问题吗 这是我的phpmailer代码: if($count){ echo "<p>New user record has been successfully inserted.</p>\n"; require_once("PHPMailer-master/class.phpmailer.php"); $mail = new PHPMailer();

我遇到了一个问题,无法通过gmail服务器使用phpMail()发送邮件。我能知道有什么问题吗

这是我的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";
}

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

您删除用户名和密码是为了不泄露它们,还是一开始就没有使用它们?我认为Gmail使用端口25@ggioffreda实际上,我删除它们是因为隐私issue@SunilPachlangia我试着将SMTPSecure改为ssl而不是tls
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