简体   繁体   中英

Cannot send mail thtrough PHP mailer through Gmail server

I am encountering a problem where i cant send mail using my phpmailer() through my gmail server. Can i know whats the problem?

This is my phpmailer code:

    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";
}

I am also encountering this problem also:

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

Did you uncomment the line extension=php_openssl.dll in your php.ini file. Gmail uses openssl, which the php file needs to recognise.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM