Sending mail (in Localhost) with CodeIgniter email

2020-07-27 04:00发布

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条回答
SAY GOODBYE
2楼-- · 2020-07-27 04:36

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'
);
查看更多
登录 后发表回答