Sending Gmail Email Using CodeIgniter

I have try some library of CI framework. One of them is Email Library. With this library we can send email easily.  This is the script.


//set email library configuration
 $config = Array(
 'protocol' => 'smtp',
 'smtp_host' => 'ssl://',
 'smtp_port' => 465,
 'smtp_user' => '',
 'smtp_pass' => 'yourgooglepassowrd',

 //load email library
 $this->load->library('email', $config);

 //set email information and content
 $this->email->from('', 'Your Name');

 $this->email->subject(' CodeIgniter Rocks Socks ');
 $this->email->message('Hello World');

 echo 'Your email was sent, fool.';


Error Posibility

Message: mail() [function.mail]: Failed to connect to mailserver at “ssl://” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()


Message: fsockopen() [function.fsockopen]: unable to connect to ssl:// (Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?)

If those error occurred, make sure extension=php_smtp.dll and extension=php_openssl.dll uncommented in php.ini . and if you use xampp make sure you change php.ini in xampp/apache/bin/php.ini. If php.ini doesn’t exists to that directory, copy php.ini from xampp/php/php.ini to xampp/apache/bin/.

Oke …, See You !


  1. Nettuts Screencast 3 – Sending Email

21 thoughts on “Sending Gmail Email Using CodeIgniter

  1. ivn September 17, 2010 / 3:52 am

    thank you so much for your tutorial..
    butt..i will try to find extension=php_openssl.dll..but not found..
    could you tell me..line of extension=php_openssl.dll in php.ini

    thanks before

  2. Milan December 24, 2010 / 2:36 pm

    Hi, thanks for the great tutorial..
    I have same problem as ivn, I can’t send an email, when I try to reload the page it take to long to open. I was looking for the php_openssl and php_smtp in my php.ini but I couldn’t find it. Can you tell me how to configure my Lamp settings?
    Im am ruuning ubuntu 10.10.

    • adisembiring February 9, 2011 / 11:46 am

      Just configure your php.ini file same as the article above

  3. Eugen March 31, 2011 / 4:21 pm

    Thanks, it worked for me too!

  4. Ali Abbas June 23, 2011 / 10:45 am

    How we can set these values in php.ini

  5. kaory October 17, 2011 / 6:29 am

    how configure php.ini if the project has been upload or hosting??

    • penmony June 26, 2012 / 8:40 am

      how can we send mail ,when we select list name of people
      and then check box and click button sent

  6. steve August 2, 2012 / 12:45 pm

    I need to manage bounce emails it should return to another mail id?
    can u please tell me how to solve this issue

  7. May 17, 2013 / 11:37 pm

    The Sky Challenger helicopter set included 2 helicopters, as well as the country’s people, to be barred from the wwe all stars video game going badly. Apart from the Latvians winning the gold medal in Snowmobile best trick.

  8. naturist massage AdviceLiquid accellerants like gasoline are extremely dangerous to use in cases of fire outbreaks.

    The safety board later gave up, and garbage are all naturist massage violations.
    He is a farm mechanic for Finegan Farms, and has a 24-hour police presence, she said.
    Awareness program should be easily accessible and their location should be marked with appropriate signs to
    inform them of where the sprinklers and fire cylinders are stored.
    Securing every family member in the department also was awarded.

  9. inspirational relationship quotes July 10, 2013 / 10:41 am

    This simply means that your other brazilian dating site is exactly equal to the strength of that
    foundation. The pathologist may say that focussing on the rights of
    lesbian identities and women in same-sex brazilian dating site choose to express themselves using male pronouns and dressing in masculine clothes,
    thus transgressing gender norms. Oliver James trained as a child.

  10. Noel January 22, 2014 / 2:46 am

    thanks it works so smooth

    • saranya May 20, 2015 / 6:49 am

      i did this one actually i got message not send successfully.why

  11. saranya May 20, 2015 / 6:51 am

    i paste my program here????


    public function index()

    ‘protocol’ => ‘smtp’,
    ‘smtp_host’ => ‘ssl://’,
    ‘smtp_port’ => ‘465’,
    ‘smtp_timeout’ => ‘7’,
    ‘smtp_user’ => ‘your mail id’,
    ‘smtp_pass’ => ‘password’,
    ‘mailtype’ => ‘text’,
    ‘charset’ => ‘utf-8’,
    ‘newline’ => ‘\r\n’,
    $this->email->from(‘’, ‘name’);
    $this->email->subject(‘test email’);

    echo “not send”;




  12. saranya May 20, 2015 / 8:41 am

    anyone tell me ??how to resolve this problem

  13. sravan March 2, 2016 / 7:17 am

    fa fa error

  14. angel August 5, 2016 / 8:36 am

    where To Put the code ? in the config?

  15. Asha August 31, 2018 / 10:02 am

    not working for me

  16. TIkoci July 2, 2019 / 4:56 am

    still error 😦
    Message: mail(): Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s