Arch 5
Arch 5
Postfix
Postfix is a mail transfer agent that according to its website (http:// Related articles
www.postfix.org/):
Postfix with SASL
attempts to be fast, easy to administer, and secure, while at the same
time being sendmail compatible enough to not upset existing users. Virtual user mail
Thus, the outside has a sendmail-ish flavor, but the inside is system
completely different. OpenDMARC
This article builds upon Mail server. The goal of this article is to setup OpenDKIM
Postfix and explain what the basic configuration files do. There are
instructions for setting up local system user-only delivery and a link to a guide for virtual user
delivery.
1 Installation
Install the postfix (https://archlinux.org/packages/?name=postfix) package.
2 Configuration
See Postfix Basic Configuration (http://www.postfix.org/BASIC_CONFIGURATION_RE
ADME.html). Configuration files are in /etc/postfix by default. The two most important files
are:
master.cf , defines what Postfix services are enabled and how clients connect to them, see
master(5) (https://man.archlinux.org/man/master.5)
main.cf , the main configuration file, see postconf(5) (https://man.archlinux.org/m
an/postconf.5)
Configuration changes need a postfix.service reload or run postfix reload in order to
take effect.
2.1 Aliases
See aliases(5) (https://man.archlinux.org/man/postfix/aliases.5).
You should map all mail addressed to root to another account since it is not a good idea to read mail
as root.
https://wiki.archlinux.org/title/Postfix 1/15
8/17/25, 12:31 PM Postfix - ArchWiki
root: you
Once you have finished editing /etc/postfix/aliases you must run the postalias command:
# postalias /etc/postfix/aliases
# newaliases
Tip
Alternatively you can create the file ~/.forward , e.g. /root/.forward for root. Specify the
user to whom root mail should be forwarded, e.g. user@localhost.
/root/.forward
user@localhost
myhostname = localhost
mydomain = localdomain
mydestination = $myhostname, localhost.$mydomain, localhost
inet_interfaces = $myhostname, localhost
mynetworks_style = host
default_transport = error: outside mail is not deliverable
All other settings may remain unchanged. After setting up the above configuration file, you may wish
to set up some #Aliases and then #Start Postfix.
https://wiki.archlinux.org/title/Postfix 2/15
8/17/25, 12:31 PM Postfix - ArchWiki
/etc/postfix/main.cf
virtual_alias_maps = lmdb:/etc/postfix/virtual
/etc/postfix/virtual
user@domain address
# postmap /etc/postfix/virtual
Restart postfix.service .
To see all of your configs, type postconf . To see how you differ from the defaults, try
postconf -n .
3 Start Postfix
Note
You must run newaliases at least once for Postfix to run, even if you did not set up any
#Aliases.
4 TLS
For more information, see Postfix TLS Support (http://www.postfix.org/TLS_README.ht
ml).
https://wiki.archlinux.org/title/Postfix 3/15
8/17/25, 12:31 PM Postfix - ArchWiki
/etc/postfix/main.cf
smtp_tls_security_level = may
To enforce TLS (and fail when the remote server does not support it), change may to encrypt .
Note, however, that this violates RFC:2487 if the SMTP server is publicly referenced.
Warning
If you deploy TLS, be sure to follow weakdh.org's guide (https://weakdh.org/sysadmin.
html) to prevent FREAK/Logjam. Since mid-2015, the default settings have been safe against
POODLE. For more information see Server-side TLS.
You need to obtain a certificate. Point Postfix to your TLS certificates by adding the following lines
to main.cf :
/etc/postfix/main.cf
smtpd_tls_security_level = may
smtpd_use_tls = yes
smtpd_tls_cert_file = /path/to/cert.pem
smtpd_tls_key_file = /path/to/key.pem
There are two ways to accept secure mail. STARTTLS over SMTP (port 587 (also called "submission"
port)) and SMTPS (port 465 (also called "submissions" port). The latter was previously deprecated
but was reinstated by RFC:8314.
To enable STARTTLS over SMTP (port 587), uncomment the following lines in master.cf :
/etc/postfix/master.cf
https://wiki.archlinux.org/title/Postfix 4/15
8/17/25, 12:31 PM Postfix - ArchWiki
/etc/postfix/master.cf
Note
The post-quantum key exchange will only be used if both the sending and receiving server
support it. Yet, there is no downside of enabling it - it will just be used opportunistically, if
possible. Some larger services like GMail offer the X25519MLKEM768 keyshare already though.
You can test whether a server supports any post-quantum algorithms by using testssl.sh (h
ttps://archlinux.org/packages/?name=testssl.sh) or using the Hardenize web
service (https://www.hardenize.com/).
/etc/postfix/main.cf
tls_eecdh_auto_curves =
tls_ffdhe_auto_groups =
tls_config_file = ${config_directory}/openssl.cnf
tls_config_name = postfix
/etc/postfix/openssl.cnf
postfix = postfix_settings
[postfix_settings]
ssl_conf = postfix_ssl_settings
https://wiki.archlinux.org/title/Postfix 5/15
8/17/25, 12:31 PM Postfix - ArchWiki
[postfix_ssl_settings]
system_default = baseline_postfix_settings
[baseline_postfix_settings]
Groups = *X25519MLKEM768 / *X25519:X448 / P-256:P-384:P-521:ffdhe2048:ffdhe3072
This enables the new post-quantum secure X25519MLKEM768 as well as the previous defaults for
traditional, non-quantum safe curves.
Note
OpenSSL also supports further post-quantum exchanges like the hybrid schemes
SecP256r1MLKEM768 and SecP384r1MLKEM1024 or using ML-KEM exclusively via
MLKEM512, MLKEM768 and MLKEM1024. For now, hybrid schemes are preferred as they
provide at least the same classical safety of X25519 and co should there be any issues found with
ML-KEM or the implementation thereof. Considering these are pretty new algorithms, it
appears as if X25519MLKEM768 is seeing most adoption for now. If wanted, any of the other
key exchange schemes could be added though, their presence wouldn't cause any problems.
Create and open /etc/postfix/blacklist_incoming file and append sender email address:
[email protected] REJECT
# postmap lmdb:blacklist_incoming
Add the following code before the first permit rule in main.cf :
5.2 Hide the sender's IP and user agent in the Received header
This is a privacy concern mostly, if you use Thunderbird and send an email. The received header will
contain your LAN and WAN IP and info about the email client you used. (Original source:
AskUbuntu (https://askubuntu.com/questions/78163/when-sending-email-with-postfi
x-how-can-i-hide-the-senders-ip-and-username-in)) What we want to do is remove the
Received header from outgoing emails. This can be done by the following steps:
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
First, go into the master.cf file in the directory /etc/postfix and change all the chroot entries
to 'yes' (y) except for the services qmgr , proxymap , proxywrite , local , and virtual
Second, create two functions that will help us later with copying files over into the chroot jail (see last
step)
cond_copy() {
# find files as per pattern in $1
# if any, copy to directory $2
dir=$(dirname "$1")
pat=$(basename "$1")
lr=$(find "$dir" -maxdepth 1 -name "$pat")
if test ! -d "$2" ; then exit 1 ; fi
if test "x$lr" != "x" ; then $CP $1 "$2" ; fi
}
$ set -e
$ umask 022
$ POSTFIX_DIR=${POSTFIX_DIR-/var/spool/postfix}
$ cd ${POSTFIX_DIR}
$ mkdir -p etc lib usr/lib/zoneinfo
$ test -d /lib64 && mkdir -p lib64
$ lt=/etc/localtime
$ if test ! -f $lt ; then lt=/usr/lib/zoneinfo/localtime ; fi
$ if test ! -f $lt ; then lt=/usr/share/zoneinfo/localtime ; fi
$ if test ! -f $lt ; then echo "cannot find localtime" ; exit 1 ; fi
$ rm -f etc/localtime
Copy localtime and some other system files into the chroot's etc
https://wiki.archlinux.org/title/Postfix 7/15
8/17/25, 12:31 PM Postfix - ArchWiki
Copy required libraries into the chroot using the previously created function cond_copy
Warning
This is not a trivial section. Be aware that you make sure you know what you are doing. You
better read Common Mistakes (https://dane.sys4.de/common_mistakes) before.
DANE supports several types of records, however not all of them are suitable in Postfix.
5.4.2 Configuration
Opportunistic DANE is configured this way:
/etc/postfix/main.cf
smtpd_use_tls = yes
smtp_dns_support_level = dnssec
smtp_tls_security_level = dane
/etc/postfix/master.cf
To use per-domain policies, e.g. opportunistic DANE for example.org and mandatory DANE for
example.com, use something like this:
https://wiki.archlinux.org/title/Postfix 8/15
8/17/25, 12:31 PM Postfix - ArchWiki
/etc/postfix/main.cf
indexed = ${default_database_type}:${config_directory}/
transport
example.com dane
example.org dane
tls_policy
example.com dane-only
Note
6 Extras
PostfixAdmin — A web-based administrative interface for Postfix.
6.1 Postgrey
Postgrey (https://postgrey.schweikert.ch/) can be used to enable greylisting for a Postfix
mail server.
6.1.1 Installation
Install the postgrey (https://archlinux.org/packages/?name=postgrey) package. To
get it running quickly edit the Postfix configuration file and add these lines:
/etc/postfix/main.cf
https://wiki.archlinux.org/title/Postfix 9/15
8/17/25, 12:31 PM Postfix - ArchWiki
smtpd_recipient_restrictions =
check_policy_service inet:127.0.0.1:10030
Then start/enable the postgrey service. Afterwards, reload the postfix service. Now
greylisting should be enabled.
6.1.2 Configuration
Configuration is done by extending the unit postgrey.service .
6.1.3 Whitelisting
To add automatic whitelisting (successful deliveries are whitelisted and do not have to wait any
more), add the --auto-whitelist-clients=N option and replace N by a suitably small
number (or leave it at its default of 5).
/etc/systemd/system/postgrey.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/postgrey --inet=127.0.0.1:10030 \
--pidfile=/run/postgrey/postgrey.pid \
--group=postgrey --user=postgrey \
--daemonize \
--greylist-text="Greylisted for %%s seconds" \
--auto-whitelist-clients
To add your own list of whitelisted clients in addition to the default ones, create the file
/etc/postfix/postgrey_whitelist_clients.local and enter one host or domain per line,
then restart postgrey.service so the changes take effect.
6.1.4 Troubleshooting
If you specify --unix=/path/to/socket and the socket file is not created ensure you have
removed the default --inet=127.0.0.1:10030 from the service file.
6.2 SpamAssassin
This section describes how to integrate SpamAssassin.
Note
If you want to combine SpamAssassin and Dovecot Mail Filtering, ignore the next two lines and
continue further down instead.
virtual_transport = dovecot
Alternately, if you do not want to use virtual transports you can use the mailbox_command (htt
p://www.postfix.org/postconf.5.html#mailbox_command). This runs with the local user
and group, whereas the pipe runs with with the specified user using the user setting.
sieve_before = /etc/dovecot/sieve.before.d/
sieve_extensions = +vnd.dovecot.filter
sieve_plugins = sieve_extprograms
sieve_filter_bin_dir = /etc/dovecot/sieve-filter
sieve_filter_exec_timeout = 120s #this is often needed for the long running spamassassin scans, default is
otherwise 10s
Create the directory and put spamassassin in as a binary that can be ran by dovecot:
# mkdir /etc/dovecot/sieve-filter
# ln -s /usr/bin/vendor_perl/spamc /etc/dovecot/sieve-filter/spamc
https://wiki.archlinux.org/title/Postfix 11/15
8/17/25, 12:31 PM Postfix - ArchWiki
require [ "vnd.dovecot.filter" ];
filter "spamc" [ "-d", "127.0.0.1", "--no-safe-fallback" ];
# cd /etc/dovecot/sieve.before.d
# sievec spamassassin.sieve
Policy services are standalone services and connected to Postfix like this:
/etc/postfix/main.cf
smtpd_recipient_restrictions =
...
check_policy_service unix:/run/policyd.sock
check_policy_service inet:127.0.0.1:10040
Placing policy services at the end of the queue reduces load, as only legitimate mails are processed. Be
sure to place it before the first permit statement to catch all incoming messages.
https://wiki.archlinux.org/title/Postfix 12/15
8/17/25, 12:31 PM Postfix - ArchWiki
/etc/postfix/main.cf
policy-spf_time_limit = 3600s
/etc/postfix/master.cf
Lastly you need to add the policyd to the smtpd_recipient_restrictions . To minimize load
put it to the end of the restrictions but above any reject_rbl_client DNSBL line:
/etc/postfix/main.cf
smtpd_recipient_restrictions=
...
permit_sasl_authenticated
permit_mynetworks
reject_unauth_destination
check_policy_service unix:private/policy-spf
/etc/python-policyd-spf/policyd-spf.conf
defaultSeedOnly = 0
/etc/postfix/main.cf
policy_time_limit = 3600
Transport:
/etc/postfix/master.cf
https://wiki.archlinux.org/title/Postfix 13/15
8/17/25, 12:31 PM Postfix - ArchWiki
Warning
/etc/postfix/main.cf
smtpd_recipient_restrictions=
...
reject_unauth_destination
check_policy_service unix:private/policy
...
/etc/postsrsd/postsrsd.conf
Enable and start the daemon, making sure it runs after reboot as well. Then configure Postfix
accordingly by tweaking the following lines:
/etc/postfix/main.cf
sender_canonical_maps = socketmap:unix:srs:forward
sender_canonical_classes = envelope_sender
recipient_canonical_maps = socketmap:unix:srs:reverse
recipient_canonical_classes = envelope_recipient, header_recipient
7 Troubleshooting
Then you can fix it by using these commands, depending on the messages you get:
postmap /etc/postfix/transport
postmap /etc/postfix/virtual
https://wiki.archlinux.org/title/Postfix 14/15
8/17/25, 12:31 PM Postfix - ArchWiki
7.2 Host or domain name not found. Name service error for name=...
If you get the following warning with journalctl:
Host or domain name not found. Name service error for name=...
It could be that you are running Postfix in a chroot and /etc/resolv.conf is missing. If so,
you can fix this by:
mkdir -p /var/spool/postfix/etc
cp /etc/resolv.conf /var/spool/postfix/etc/resolv.conf
If you get this error when running sievec after following #SpamAssassin combined with
Dovecot LMTP / Sieve, replace sieve_extensions with sieve_global_extensions in
/etc/dovecot/sieve.before.d/spamassassin.sieve .
Restart dovecot.service .
8 See also
Official documentation (http://www.postfix.org/documentation.html)
Postfix Ubuntu documentation (https://help.ubuntu.com/community/Postfix)
Virtual user mail system with Postfix, Dovecot and Roundcube
https://wiki.archlinux.org/title/Postfix 15/15