How to set up CodeIgniter in order to use Gmail for emails

Now and then and… every time… I see people complaining that the email library of CodeIgniter doesn’t work. Why? Because they are using Gmail in order to send emails. And they are shocked that it doesn’t work. But in order to use Gmail as an email sender from your CodeIgniter, you have to know a couple of things.

1. The correct CI email library settings

Create an email.php file inside your application/config directory and put this in it:

Now just test it inside a controller:

Did it send? If the answer is “Yes”, then good for you. If the answer is “No”, then you need to follow two more steps:

2. The correct IMAP forwarding

Go to your Gmail, then to settings, and select the “Forwarding and POP/IMAP” tab. From there make sure you have IMAP access enabled.

3. Less security…

Go to and then scroll down to “Allow less secure apps”. Make sure that is set to… ON. If all this didn’t help you, then fine by me…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.