Support Centre Documentation

Setup SMTP with Google Mail


SMTP is an email protocol that allows you to send emails in a more reliable way than using PHP's mail() function. In this tutorial, we'll show you how you can setup SMTP to send emails by using Google's GMail service.

First, you will need a Gmail account. You can sign up for free at: https://mail.google.com.

First, let's setup your Google Account to allow for it to send emails via SMTP. You to enable Less Secure Apps option in your account, which you can do so by going to Your Account settings. Or you can click here: https://myaccount.google.com/lesssecureapps

 

Now that your Google Account is available for sending emails via SMTP, you can now configure your CodeIgniter script to use it. Open up the file: application/config/email.php and add the following settings:

 

$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'Google_email_address';
$config['smtp_pass'] = 'Google_email_password';
$config['smtp_port'] = 465; 
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;

 

Make sure to not have any old config values and just have the ones above. Make sure to replace Google_email_address and Google_email_password with your own details.

Your system is now setup to use SMTP and emails will now be sent from the Google server.