Sendmail Notes

Install Sendmail in Ubuntu
$ sudo apt-get update
$ sudo apt-get install sendmail
$ sudo sendmailconfig

Test sending an email:
echo "Subject: sendmail test" | sendmail -v mindaji@gmail.com
echo "This is the body of the email" | mail -s "This is the subject line" mindaji@gmail.com

To allow connections from ALL hosts/LAN IPs open sendmail.mc file (login as the root):

# vi /etc/mail/sendmail.mc

Look for line that read as follows:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

Comment or remove above line and insert new line that read as follows:

DAEMON_OPTIONS(`Port=smtp,Name=MTA’)dnl

Regenerate the cf file
m4 sendmail.mc > sendmail.cf
or
sudo bash -c 'cd/etc/mail/ && m4 sendmail.mc >sendmail.cf'

Example for further configuration
After installing sendmail , you should configure sendmail. It`s little hard. But don`t worry after that we can spoof email to anyone.

Type following command on terminal

sudo gedit /etc/mail/sendmail.mc

It will open sendmail.mc file.

For example your last two lines are as follow

MAILER(`local')dnl

MAILER(`smtp')dnl

Put this code before that two lines.

MAILER_DEFINITIONS

define('SMART_HOST',`smtp.gmail.com')

Ok. now close that file

Now we will generate configure file from .mc file so type following command in terminal.

sudo bash -c 'cd/etc/mail/ && m4 sendmail.mc >sendmail.cf'

Using gmail smtp as the external smart host

https://linuxconfig.org/configuring-gmail-as-sendmail-email-relay

Linux Email Servers Notes