Skip to Content

Configure SMTP on Ezeelogin Jump server

How to configure SMTP relay with Sendmail?


Overview: This article describes the steps to configure an SMTP relay using Sendmail on Linux-based systems, enabling secure email transmission via an external SMTP server.


Install Sendmail

In Ubuntu / Debian systems

root@gateway:~# apt install sendmail 

 In Centos/RHEL

root@gateway:~# yum install sendmail

Step 1: Create Authentication file.
Create a directory in /etc/mail directory 

root@gateway:~# sudo mkdir /etc/mail/authinfo

root@gateway:~# sudo chmod 700 /etc/mail/authinfo

Step 2: Create an authentication file and add the following. Replace the following email with your mail credentials.

root@gateway:~# sudo vi /etc/mail/authinfo/smtp-auth

AuthInfo: "U:root" "I:[email protected]" "P:PASSWORD"

 Create a hash map file of the above authentication file as follows

root@gateway:~# makemap hash /etc/mail/authinfo/smtp-auth < /etc/mail/authinfo/smtp-auth

Step 3: Configure Sendmail 
 
Add the following parameters into your sendmail.mc configuration file below the "MAILER_DEFINITIONS" definition.
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/smtp-auth.db')dnl
 Save and re-build sendmail configuration 
 

root@gateway:~# make -C /etc/mail

Step 4: Restart the mail server
 

root@gateway:~# service restart sendmail

Now send a test email 

 

root@gateway:~# echo 'e-Mail TEST SMTP RELAY'| mail -s TESTMAIL [email protected]


Related Articles:
How to enable mail notification in Jumpserver.