Postfix for outgoing emails

DEPRECATED – we now use null-mailers as a null-mailer

Introduction

You have a few choices to make

Note that DMA is like Sendmail. You absolutely need to define an FQDN somewhere. It is fine if you just tune your /etc/hosts file enough, while using a short hostname, though. Beware that you need an FQDN for your cluster names even (in case it is the same name as for the public network).

#cluster network
x.x.x.x        FQDN SHORT

#public
x.x.x.x        FQDN SHORT

Mail aliases

...

newaliases
#postalias /etc/mail/aliases

Setup

standalone FQDN + listen for bounces

    #/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

distro’s defaults are fine already (be it netbsd, ubuntu or debian)

grep ^alias /etc/postfix/main.cf
    grep ^mydestination /etc/postfix/main.cf

but on slackware you need to disable nis

    alias_maps = hash:/etc/aliases

relay-all to smarthost + pseudo-masquerade

NO NEED TO LISTEN ON INET/INET6 (unix socket 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?

smarthost=x.x.x.x
#nmap -p 25,465,587 $smarthost
nc -vz $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

myorigin = $mydomain
relayhost = x.x.x.x

grep ^alias /etc/postfix/main.cf

Operations

postfix check && echo OK || echo FAIL
systemctl restart postfix

ls -lF /etc/postfix/makedefs.out
rm -f /etc/postfix/makedefs.out

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


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun