INSTALLING POSTFIX

NETBSD INSTALL

it is built-in. if you want a newer version, Postfix builds on NetBSD as well (see below).

echo $PKG_PATH
pkg_add py37-spf py37-policyd-spf
which policyd-spf

grep ^postfix /etc/defaults/rc.conf

DEBIAN/UBUNTU INSTALL

export DEBIAN_FRONTEND=noninteractive
apt -y install postfix postfix-pcre bsd-mailx postfix-policyd-spf-python
#mailutils pmailq rsyslog
#postfix-policyd-spf-perl

systemctl status postfix

SLACKWARE INSTALL

slackpkg install postfix icu4c cyrus-sasl procmail ksh alpine
ldd /usr/sbin/postfix
ls -lhF /etc/rc.d/rc.postfix
chmod +x /etc/rc.d/rc.postfix

FROM SCRATCH

Building Postfix 3.x on slackware 14.2,current and NetBSD 7,8,9

Why build from scratch? So we get PCRE, DOVECOT-SASL and LIBSPF2 up and running

slackware requirements

for receiving keys through GPG

slackpkg install nghttp2 brotli cyrus-sasl

for building

slackpkg install guile gc db48 glibc kernel-headers m4 pcre

how many cores for make jobs?

grep ^proc /proc/cpuinfo

netbsd requirements

although we are going to use Dovecot’s implementation of SASL, we could not get around this library

pkg_add cyrus-sasl
#cd /usr/pkgsrc/security/cyrus-sasl/
#make install
ll /usr/pkg/lib/sasl2/ #old
ll /usr/pkg/etc/sasl2/ #new
#security/cy2-crammd5
#security/cy2-gssapi

also we are going to enable SPF

pkg_add py-policyd-spf
#cd /usr/pkgsrc/mail/py-policyd-spf/
#make install

also make sure you’ve got those

    grep postfix /etc/passwd
    grep postfix /etc/group
    grep maildrop /etc/group

how many cores for make jobs?

dmesg | egrep '] cpu[0-9]+:'

fetching the source

grab the latest release from a mirror and the .gpg2 signature. The .gpg1 one is using Wietse old and revoked key (C12BCD99).

ver=3.5.2

#FRANCE
#mirror=http://postfix.mirrors.ovh.net
#BULGARIA
mirror=http://mirror.host.ag/postfix

wget $mirror/postfix-release/official/postfix-$ver.tar.gz
wget $mirror/postfix-release/official/postfix-$ver.tar.gz.gpg2

you can use GPG v1

gpg --verify postfix-$ver.tar.gz.gpg2 postfix-$ver.tar.gz
gpg --recv-keys 80CA15A7
gpg --verify postfix-$ver.tar.gz.gpg2 postfix-$ver.tar.gz

you should have a good signature with this fingerprint

Primary key fingerprint: 622C 7C01 2254 C186 6774  69C5 0C0B 590E 80CA 15A7

extract it and compile with SSL and SASL

tar xzf postfix-$ver.tar.gz
cd postfix-$ver/

netbsd specific

vi makedefs

   NetBSD*) SYSTYPE=NETBSD

vi src/util/sys_defs.h 

    || defined(NETBSD) \

building

build postfix

make tidy
make makefiles CCARGS="-I/usr/local/include -DHAS_PCRE -DUSE_TLS -DUSE_SASL_AUTH" AUXLIBS="-L/usr/lib64 -L/usr/local/lib -lpcre -lssl -lcrypto"
#-DDEF_SERVER_SASL_TYPE=\"dovecot\"
time nice make -j2 > ../postfix.log && echo BUILT
make install

…eventually accept all the defaults, overriding system’s built-in version

which postfix
which postconf
postconf -d | grep mail_version

check that you got Dovecot SASL enabled

postconf -a

check configuration

postfix check && echo ok

TROUBLESHOOTING

postfix/master[7421]: warning: process /usr/libexec/postfix/smtpd pid 7565 killed by signal 6
postfix/master[7421]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

ll /etc/postfix/
chown -R root:wheel /etc/postfix/

ll /usr/libexec/postfix/
chown -R root:wheel /usr/libexec/postfix/

ll /usr/sbin/post*
ll /usr/sbin/sendmail
chown root:wheel /usr/sbin/post*
chown root:wheel /usr/sbin/sendmail
chown root:maildrop /usr/sbin/postqueue
chown root:maildrop /usr/sbin/postdrop
chmod g+s /usr/sbin/postqueue
chmod g+s /usr/sbin/postdrop

ll /usr/bin/newaliases
ll /usr/bin/mailq
chown root:wheel /usr/bin/newaliases
chown root:wheel /usr/bin/mailq

getting this while building with PCRE on slackware

/usr/bin/ld: ../../lib/libutil.a(dict_pcre.o): in function `dict_pcre_close':
/root/tp/postfix-3.5.2/src/util/dict_pcre.c:395: undefined reference to `pcre_free_study'
/usr/bin/ld: /root/tp/postfix-3.5.2/src/util/dict_pcre.c:404: undefined reference to `pcre_free_study'
/usr/bin/ld: ../../lib/libutil.a(dict_pcre.o): in function `dict_pcre_lookup':
/root/tp/postfix-3.5.2/src/util/dict_pcre.c:316: undefined reference to `pcre_exec'
/usr/bin/ld: /root/tp/postfix-3.5.2/src/util/dict_pcre.c:355: undefined reference to `pcre_exec'
...

==> RTFM: http://www.postfix.org/PCRE_README.html

RESOURCES

Postfix Installation From Source Code http://www.postfix.org/INSTALL.html

NetBSD mail server with Postfix, BIND (for DNS), Dovecot, Pigeonhole (Sieve), SSL, DKIM and SPF http://silas.net.br/tech/apps/netbsd-mailserver.html

Complete (almost) Mail Server with NetBSD https://www.tumfatig.net/20101226/complete-almost-mail-server-with-netbsd/

Postfix PCRE Support http://www.postfix.org/PCRE_README.html

Postfix SASL Howto http://www.postfix.org/SASL_README.html

SASL https://wiki.dovecot.org/Sasl

Postfix and Dovecot SASL https://wiki.dovecot.org/HowTo/PostfixAndDovecotSASL


HOME | GUIDES | BENCHMARKS | html