Is it possible to use gmail as the smtp server for sending e-mail out from ExpressionEngine? It looks like you need to be able to set a different port and i'm not sure you can do it from the E-mail config page in the EE admin area?

  • Do you specifically want to use Gmail, or would you be open to the idea of using a transactional email service like Sendgrid or Mandrill? Only reason I ask this, is I have a lot of experience using other email services within EE, just no experience with Gmail. Nov 25, 2012 at 0:50
  • Gmail specifically, especially without using a third party add-on, i'm sure you must be able to do this natively in the config.php somewhere perhaps?... Nov 25, 2012 at 0:55
  • I won't make this an official answer, as it's untested and more or less a suggestion. But go to Admin > Email Configurations and enter your SMTP information for Gmail. I bet that works. If so, answer your own question based on my comments (or I can make an official answer). Nov 25, 2012 at 1:02
  • Why are you using Gmail to send email? If you are just testing, use MailTrap.io. If you are looking for a cheap/free production solution, use Mandrill. Jul 10, 2013 at 3:01

3 Answers 3


With Google's move toward stricter security measures regarding how third-parties connect with their services, there's now another step required to set up ExpressionEngine to send email through Gmail. Beginning to end, here's how to do it.

Step 1: Allow "Less Secure Apps" to Access Gmail

Sign in to the Gmail (or Gmail-powered Google Apps) account you want to use and open up the "less secure apps" section under My Account.

Turn on access for less secure apps.

Step 2: Configure ExpressionEngine

In your config.php file, copy over these config items and modify the username and password. Note that the username must be the full email address, and the value for $config['email_newline'] must be enclosed in double quotes.

$config['mail_protocol'] = 'smtp';
$config['email_newline'] = "\r\n";
$config['email_smtp_crypto'] = 'ssl';
$config['smtp_server'] = 'smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_username'] = '[email protected]';
$config['smtp_password'] = 'xxxxxxxxx';

This has been tested thoroughly in ExpressionEngine 2.10.1, though given the availability of config overrides, it should work with EE 2.6+. For older versions, just omit the line for $config['email_smtp_crypto'] and use ssl://smtp.gmail.com as the value for $config['smtp_server'].

Step 3: Test

Make sure it works before you push these changes live. I haven't tested in all possible network configurations or with all possible EE versions. If you find a scenario that requires something different, drop it in the comments.


Pretty sure because of Gmail's forced use of SSL connections this work around is still required in EE 2. I don't remember this being corrected in recent releases of EE v2 but I could be mistaken:


  • It would be great if someone could copy the actual workaround here, rather than linking to a forum thread people need to dig through to find the solution. Jan 3, 2013 at 18:16

I don't know if this will work for you or not, but I was able to set up Google smtp over TLS with a few additions to the config:

$env_conf['mail_protocol']    = 'smtp';
$env_conf['smtp_server']      = 'tls://smtp.gmail.com:XXX';    // Use :XXX to set the port number.
$env_conf['smtp_username']    = '[email protected]';
$env_conf['smtp_password']    = 'xxx';
$env_conf['email_newline']    = "\r\n";
$env_conf['email_crlf']       = "\r\n";
$config['smtp_port'] = "xxx"; //replace with your port number

In my particular case I just added the last 3 to a config bootstrap and set up the rest through the cpanel.

Most of this came from this Gist https://gist.github.com/experience/2557044 and the EE hidden config vars docs: http://ellislab.com/expressionengine/user-guide/general/hidden_configuration_variables.html#smtp-port

Hopefully that works for someone :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.