Configuring Sendmail SMTP Relay on Ubuntu and Linux

Configuring-Sendmail-SMTP-Relay-on-Ubuntu-and-Linux

Note: domainname —> replace with you domain name

sudo apt remove postfix && apt purge postfix
sudo apt install sendmail
cd /etc/mail
mkdir -m 700 -p /etc/mail/authinfo
nano /etc/mail/authinfo/authinfo
add line in that file
AuthInfo: “U:root@domainname.com” “I:root@domainname.com” “P: Email id Password”

Note: create name root email id in you email provider or user any already created email id

cd /etc/mail/authinfo
makemap hash auth-info < auth-info

Configure your sendmail.mc

Open /etc/mail/sendmail.mc file in your text-editor and copy the follow lines and paste before the first MAILER line:
dnl # Defining smtp Smarthost for sendmail
define(SMART_HOST',mail.domainname.com’)dnl
define(RELAY_MAILER_ARGS',TCP $h 587′)dnl
define(ESMTP_MAILER_ARGS',TCP $h 587′)dnl
FEATURE(authinfo',hash -o /etc/mail/authinfo/authinfo.db’)dnl
FEATURE(genericstable',hash -o /etc/mail/genericstable.db’)dnl
GENERICS_DOMAIN_FILE(/etc/mail/generics-domains')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

dnl FEATURE(masquerade_entire_domain)dnl
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
dnl MASQUERADE_DOMAIN(domainname.io)dnl
MASQUERADE_AS(domainname.com')dnl FEATURE(masquerade_envelope)dnl FEATURE(masquerade_entire_domain)dnl MASQUERADE_DOMAIN(domainname.io)dnl define(MAIL_HUB’, domainname.com')dnl define(LOCAL_RELAY’, `domainname.com’)dnl

cd /etc/mail

m4 sendmail.mc > sendmail.cf

service sendmail restart
$ echo ‘e-Mail TEST’| mail -s TEST email@yourdomain.com

Related posts

Creating a Bootable Installation Media for Ubuntu OS

Secure Your Website with Let’s Encrypt and Nginx: A Step-by-Step Guide

Monitoring Calls with FreeSWITCH CLI: A Comprehensive Guide