简体   繁体   中英

Unable to sent mail by using gmail smtp server

Hi i am unable to use gmail smtp service to send email from my website which is develop by using cakephp3.x of the php framework. Blow is the error i am getting

stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed stream_socket_client(): Failed to enable crypto stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) 

Here is my code

Email::configTransport('gmail', [
            'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
            'timeout' => '30',
            'username' => 'pradeepta20@gmail.com',
            'password' => '******',
            'className' => 'Smtp' // <------ there it is
        ]);
        $email_obj = new Email();
        $email_obj->template('default')
                ->emailFormat('html')
                ->to("pradeepta20@gmail.com")
                ->from(["someone@gmail.com" => "Test"])
                ->subject("Testing STMP EMAIL")
                ->transport('gmail');

        if ($email_obj->send("Some Text Message"))
            echo "Email Sent!!";
        else
            echo "Error!!";
        exit;

If your device or application supports SSL - connect to smtp.gmail.com on port 465.则在Google帮助网站中有一句话ssl://因此,请尝试从主机中删除ssl://前缀。

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