Configuring Gmail as a Sendmail Email Relay

Configuring Gmail as a Sendmail Email Relay

Configuring Gmail as a Sendmail Email Relay:

In this tutorial we will help you the configuration process of configuring Gmail as a Sendmail Email Relay.

 

Install Prerequisites:

Before configuring gmail as a sendmail email relay make sure all required packages has been installed on your system. Run below command to install the required packages.

# yum install sendmail mailutils sendmail-bin

Create Authentication File:

Now you need to create a directory to store a file which contains gmail credentials to access the smtp server.

# mkdir -p /etc/mail/auth
# chmod 700 /etc/mail/auth

Now create a authentication file and add the below content.

# vim /etc/mail/auth/auth-file
AuthInfo: "U:root" "I:Your Gmail Account Email I'd" "P:PASSWORD"

After creating the authentication file, we will need to create a hash map for the above authentication file:

# makemap hash /etc/mail/auth/auth-file < /etc/mail/auth/auth-file

Configure Your Sendmail:

Put bellow lines into your sendmail.mc configuration file below “MAILER” definition line:

# vim /etc/mail/sendmail.mc
define(`SMART_HOST',`[smtp.gmail.com]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/auth-file.db')dnl

Now execute below command to re-build sendmail’s configuration.

# make -C /etc/mail

Verify Configuration:

After all the configuration first we need to reload the sendmail service.

# service sendmail reload

Now send a test email to verify configuration.

# echo "Sample Email to Verify Configuration" | mail -vs "Subject Here" recipient@example.com 

Was this Tutorial helpful? Help others share on Facebook, Twitter, and Google Plus!

 

 
Enjoyed this video?
Configuring Gmail as a Sendmail Email Relay
"No Thanks. Please Close This Box!"