How to Send Gmail using CodeIgniter Email Library

In this post I would like to show you configuring Codeigniter email library to send emails using GMail SMTP server. Configuring and sending emails in Codeigniter application is not a tedious task, it is very simple and easy with few lines of code and config values you can send emails. You can set configuration options on fly or you can set config options of email library globally at applications/config/email.php.

Now I will explain how to send email using PHP and CodeIgniter Framework,you must load email library in order to send emails.

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 .If you are using 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/.

$this->email->set_newline enclose with double quotes. This is very important or else it does not work.Because PHP interpreter will consider \n as new line only when it is in enclosed with double quotes and if it in single quotes interpreter consider it as the literal character. So have a eye on it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets. Protection Status