OpenSMTPD Howto (2)

From RaySoft

Installation

Update the system:

sudo dnf updateinfo
sudo dnf -y upgrade

Install the required packages:

sudo dnf -y install 'opensmtpd'

Define OpenSMTPD as default mail daemon

sudo alternatives --set 'mta' '/usr/sbin/sendmail.opensmtpd'
sudo alternatives --display 'mta'

Configuration

Edit the configuration file:

Create a Google App Password.

Create file with the credentials:

cd '/etc/opensmtpd'

for file in 'secrets' 'secrets.db'; do
  sudo install --group='smtpd' --mode=0640 '/dev/null' "${file}"
done

sudo echo 'gmail alex.the.lion@gmail.com:**********' >>'secrets'

sudo makemap 'secrets'

Validate the configuration:

sudo smtpd -n

Start the service & get its status:

sudo systemctl start 'opensmtpd.service'
sudo systemctl status 'opensmtpd.service'

Observe its logs:

sudo journalctl --unit='opensmtpd.service' --since 'today' --follow

Enable the service & check it:

sudo systemctl enable 'opensmtpd.service'
sudo systemctl list-unit-files | grep 'opensmtpd.service'

Test

Observe its open ports
sudo lsof -a -c 'smtpd' -i -n -P

Output:

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
smtpd   55503 smtpd   10u  IPv4 183344      0t0  TCP 127.0.0.1:25 (LISTEN)
smtpd   55503 smtpd   11u  IPv4 183345      0t0  TCP 10.88.0.1:25 (LISTEN)
Send a test email
sendmail -t -v

Content:

To: root
Subject: Test OpenSMTPD

This an OpenSMTPD test!