How to Configure Gmail as a Sendmail email relay | How to Configuring Sendmail to Relay Emails using Gmail SMTP #linuxtopic

Linuxtopic
0
Configure sendmail, configure sendmail to send email from gmail, sendmail gmail configuration,configure sendmail centos 7, Configuring Gmail as a Sendmail email relay, configure sendmail as relay, How to Configure  Sendmail to Relay Emails using Gmail SMTP, install sendmail
Configure Sendmail using Gmail SMTP Relay

Configure sendmail, configure sendmail to send email from gmail, sendmail gmail configuration,configure sendmail centos 7, Configuring Gmail as a Sendmail email relay, configure sendmail as relay, How to Configure  Sendmail to Relay Emails using Gmail SMTP, install sendmail

In this topic we will configure internal sendmail of linux to gmail as relay using our existing gmail account.
Basic Information :

Gmail:
smtp.gmail.com

OS:
CentOS 7 - 64bit

Hostname:
lokesh.linuxtopic.com
192.168.156.100

Require Packages:
sendmail
mailx


Configure Postfix as Gmail SMTP Relay - Click Here..

Configure Sendmail as Gmail SMTP Relay 


To Install Sendmail package

yum install sendmail sendmail-cf cyrus-sasl-plain cyrus-sasl-md5 mailx


Configuration file path and file

cd /etc/mail/

Generate certificate for sendmail

cd /etc/pki/tls/certs
make sendmail.pem



Configuration Gmail Authentication

We will create auth file, that will store the authentication details to my Gmail account. if you dont have gmail Click here to create 

To Create a directory called my-auth inside /etc/mail to keep this file separate form other files and set the proper permission 
mkdir /etc/mail/my-auth
chmod 700 /etc/mail/my-auth
To create gmail-info file and type the following lines and save
vi /etc/mail/my-auth/gmail-info
AuthInfo:smtp.gmail.com "U:lokesh" "I:linuxtopic2015@gmail.com" "P:wwwwxxxxyyyyzzzz"
AuthInfo:smtp.gmail.com:587 "U:lokesh" "I:linuxtopic2015@gmail.com" "P:wwwwxxxxyyyyzzzz"
Note: In the above we used gmail SMTP Server with 587 Port and email id which we want to send email from linux box with password, we do not use actual password here generate 16 character app password and use here. 




Create gmail-info.db file 

cd /etc/mail/my-auth
makemap -r hash gmail-info.db < gmail-info
chmod 600 gmail-info gmail-info.db



Configure Sendmail :

We will create a backup file before the configure sendmail to send email via email SMTP Relay, and then we will add below line

Backup:

cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc-`date -I`

Configure SMTP Relay

Open sendmail.mc file, find the line "MAILER(smtp)dnl" and add below line above the match.

vi  /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/my-auth/gmail-info.db')dnl
After adding look like:


To re-build the sendmail configuration

make -C /etc/mail

To allow SMTP service in firewall

firewall-cmd --permanent --add-service=smtp

Now we did all the required configuration and going to restart the sendmail service, make sure postfix service is disabled and stopped

To stop and disable if postfix is running 

systemctl stop postfix && systemctl disable postfix
To start and enable sendmail 

systemctl enable sendmail && systemctl restart sendmail
To send test email

We can test sendmail using mail command below
echo "This is sendmail configuration using Gmail SMTP Relay by LinuxTopic" | mail -s "message" lokesh@linuxtopic.com

Verify from email



To check logs
For troubleshooting we can check logs as well

tail -f /var/log/maillog




Thanks you !!

I hope this topic gave you all the information you needed. If you have any further questions or would like more detailed directions feel free to contact us using any of the following sources.We look forward to talking to you.

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Ok, Go it!