Sendmail MTA Setup on Linux & SMTP Relay

๐Ÿ’ก Sendmail MTA Setup on Linux & SMTP Relay โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Sendmail MTA Setup on Linux & SMTP Relay.

bash
#!/bin/sh

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y libsasl2-modules sasl2-bin
sudo apt-get install -y libsasl2-2
sudo apt-get install -y sendmail

sudo sed -i "s/127.0.0.1 localhost/127.0.0.1 localhost.localdomain localhost/" /etc/hosts

sudo bash -c "cat << 'END_HELP' >> /etc/mail/sendmail.mc
TRUST_AUTH_MECH(\`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
END_HELP"
sudo bash -c "cat << 'END_HELP' >> /etc/mail/sendmail.mc
define(\`confAUTH_MECHANISMS', \`EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
END_HELP"

sudo sh -c "m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf"

sudo sh -c "echo Connect:172.16                    RELAY >> /etc/mail/access"
sudo sh -c "makemap hash /etc/mail/access < /etc/mail/access"

cd /usr/lib/sasl2/
sudo bash -c 'cat << EOF > Sendmail.conf
pwcheck_method:saslauthd
EOF'

sudo systemctl restart saslauthd
sudo saslauthd -a pam

sudo useradd -m -s /bin/false mailsender
sudo sh -c "echo mailsender:Mailsender123@ | sudo chpasswd"

sudo systemctl restart sendmail
  • Mail sending test

1. Connect to port 25 using Telnet

2. Say hello with the HELO \ command.

3. Specify the sender using the MAIL FROM:\ command

4. RCPT TO:\ Specify recipient with command

5. Communicating the intention to input text using the DATA command

6. Enter text

7. . After entering, press Enter โ†’ Notification of completion of text input

8. Quit with quit command

  • auth authentication test
  1. echo -ne โ€œ\\0mailsender\\0Mailsender123@โ€ \| base64
  2. Copy the base64 result from the above command
  3. telnet localhost 25
  4. ehlo localhost
  5. auth plain AG1haWxzZW5kZXIATWFpbHNlbmRlcjEyM0A=
  6. When the message โ€œOk Authenticatedโ€ appears, authentication is successful.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *