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

13,859

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' =>  '[email protected]',
    'smtp_pass' =>  'PASSWORD',
    'smtp_port' =>  '465'
);
Share:
13,859
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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'=>'[email protected]',
            'smtp_pass'=>"PASSWORD",
            'smtp_port'=>'456'
            );
            $this->load->library("email", $configs);
            $this->email->set_newline("\r\n");
            $this->email->to("[email protected]");
            $this->email->from("[email protected]", "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.