简体   繁体   English

无法通过使用Gmail SMTP服务器发送邮件

[英]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. 嗨,我无法使用gmail smtp服务从我的网站发送电子邮件,该网站是通过使用php框架的cakephp3.x开发的。 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://前缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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