Sending mail (in Localhost) with CodeIgniter email() library from gmail does not work

北慕城南 提交于 2019-12-06 11:07:37

问题


I have set the codeIgniter email() to send email from my Google Account, but it errors. It does not work, it says it cannot connect to the server or that the server party does not respond.

I have enabled (uncommented) these extensions in php.ini:

extension=php_sockets.dll
extension=php_openssl.dll

Here is my CI configurations:

$configs = array(
        'protocol'=>'smtp',
        'smtp_host'=>'ssl://smtp.gmail.com',
        'smtp_user'=>'cgmaster.iran@gmail.com',
        'smtp_pass'=>"PASSWORD",
        'smtp_port'=>'456'
        );
        $this->load->library("email", $configs);
        $this->email->set_newline("\r\n");
        $this->email->to("mostafatalebi@rocketmail.com");
        $this->email->from("cgmaster.iran@gmail.com", "Mostafa Talebi");
        $this->email->subject("This is bloody amazing.");
        $this->email->message("Body of the Message");
        if($this->email->send())
        {
            echo "Done!";   
        }
        else
        {
            echo $this->email->print_debugger();    
        }

And here is the first line of the Error that I am getting:

The following SMTP error was encountered: 10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 

回答1:


What version of CI are you using? If it's 2.1.4 then there is a discrepancy in your config array. Try this:

$configs = array(
    'protocol'  =>  'smtp',
    'smtp_host' =>  'ssl://smtp.gmail.com',
    'smtp_user' =>  'cgmaster.iran@gmail.com',
    'smtp_pass' =>  'PASSWORD',
    'smtp_port' =>  '465'
);


来源:https://stackoverflow.com/questions/20647386/sending-mail-in-localhost-with-codeigniter-email-library-from-gmail-does-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!