WarpConduit Computing

  • Quick Tips
  • Web Development
  • WordPress Plugins
  • Home
  • Passphrase Generator
  • Password Generator
  • About
  • Contact

Configuring Exim for Authenticated SMTP Relay to Gmail on CentOS/RHEL

May 14, 2016 by Josh Hartman

exim-gmail-smtp-relayI’ll start this by saying that Exim is slightly more difficult to configure for Gmail SMTP relay than Postfix, and if you’re using Webmin there is a standard module for Postfix that makes it even easier. Finding the correct way to configure Exim on CentOS was difficult in itself and the reason for this article.

Now, if you prefer to use Exim for sending mail through Gmail this is how you accomplish it.

These instructions have been tested on CentOS 6.7 with Exim 4.84.

Preparation

Log in to the Google/Gmail account you will be using for relaying and enable access from less secure apps in the security options. If you don’t make this change you will not be able to authenticate with Gmail to send mail. From my experience, Postfix and Exim both require this.

If you have Postfix or another MTA already installed you’ll want to remove them or disable them.

Next, make sure you have Exim and the SASL authentication methods installed by running:

yum install -y exim cronie cyrus-sasl cyrus-sasl-plain

Note: I’ve included cronie since it gets removed if you uninstall Postfix and other MTAs.

If that completed without errors you’re ready to continue.

Configuration

Using your favorite editor, open /etc/exim/exim.conf and find the following sections:

begin routers

Below it, add these lines:

send_via_gmail:
 driver = manualroute
 domains = ! +local_domains
 transport = gmail_smtp
 route_list = * smtp.gmail.com

Continue to the next section:

begin transports

Below it, add these lines:

gmail_smtp:
   driver = smtp
   port = 587
   hosts_require_auth = *
   hosts_require_tls = *

Continue to the next section:

begin authenticators

Below it, add these lines:

gmail_login:
   driver = plaintext
   public_name = LOGIN
   client_send = : user@gmail.com : myPassw0rd

Replace the credentials with your actual credentials on the client_send line.

That’s it for the configuration. If you started with a default exim.conf then your updated configuration file will look like this gist.

Restart Exim to make these changes live:

service exim restart

Testing & Troubleshooting

Test by sending an email with echo "Just testing." | mail -s "Test Subject" user@example.org or a simple PHP script. Use a destination address separate from the one you’re using to relay email.

Shortly thereafter you should receive the email at the destination mailbox (check the spam folder too). If you don’t receive it then check the log at /var/log/maillog or /var/log/exim/main.log for errors.

If you get an error from Gmail, they usually reference a URL in the error that you can visit for more info. You can also do a Google search for the error to see what others have done to resolve it.

Of course, the hope is that you didn’t have any errors and you’re all set to send emails from your Linux box. Enjoy!

As a side note, if you are using Webmin there is a third-party Exim module that allows you to view the Exim logs, queue, and statistics.

Conclusion

Perhaps you found this article useful or have an issue that you couldn’t resolve with a Google search? Leave a comment and see what becomes of it.

Filed Under: Computers Tagged With: centos, exim, gmail, linux, relay, rhel, smtp

Comments

  1. Joel says

    August 9, 2017 at 2:09 AM

    Thank you so much for this guide, do you know how I can change the info from gmail to G Suite though? Or is it the same info?

    • Josh Hartman says

      August 10, 2017 at 10:02 AM

      Yes, you can use smtp.gmail.com for G Suite according to this article: https://support.google.com/a/answer/176600?hl=en

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • How to Permanently Remove the “Learn about this picture” Spotlight Wallpaper Icon From Your Windows Desktop
  • How to Quickly Test a Fax Machine
  • Extremely Useful Applications for Web Development and IT Tasks

Tags

automatic benchmark bigint class composer css embed escape event font function gzip helper htaccess html htmlspecialchars image increment javascript jquery list magento media mysql number observer opencart order output photo php profiling random redirect rijndael software text type ubuntu url windows windows 7 wordpress xampp xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2025 WarpConduit Computing. All Rights Reserved.