Outgoing emails w/ Postfix

Mail aliases

#netbsd/slackware
cp -i /etc/mail/aliases /etc/mail/aliases.dist
vi /etc/mail/aliases

#ubuntu
cp -i /etc/aliases /etc/aliases.dist
vi /etc/aliases

root:       REAL-EMAIL-ADMIN

newaliases

Postfix KISS

NO NEED TO LISTEN (daemon started is enough)

mv -i /etc/postfix/master.cf /etc/postfix/master.cf.dist
sed '/^[[:space:]]*$/d; /^[[:space:]]*#/d' /etc/postfix/master.cf.dist > /etc/postfix/master.cf
vi /etc/postfix/master.cf

#smtp      inet  n       -       y       -       -       smtpd

can you reach your relay?

nmap -p 25,465,587 SMARTHOST
nc -v -z SMARTHOST 25 465 587

now define it

#/usr/share/postfix/main.cf.debian
mv -i /etc/postfix/main.cf /etc/postfix/main.cf.dist
sed '/^[[:space:]]*$/d; /^[[:space:]]*#/d' /etc/postfix/main.cf.dist > /etc/postfix/main.cf
vi /etc/postfix/main.cf

relayhost = x.x.x.x

Operations

postfix check
service postfix restart

Re-deliver

check the destination

head -20 /var/mail/root | grep To

re-deliver previously stored messages while checking the mail logs

ls -ldF /var/mail/
ls -lF /var/mail/
formail -s sendmail -t < /var/mail/root && rm -f /var/mail/root
mailq

Acceptance

tail -F /var/log/maillog
tail -F /var/log/mail.log
date | mail -s `hostname` root

Resources

Postfix https://calomel.org/postfix.html

Chapter 27. Mail and news https://www.netbsd.org/docs/guide/en/chap-mail.html


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml