Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Configure Postfix to Forward e-mail


Configure postfix to use gmail as a mail relay.

Extra Step

apt install libsasl2-modules


Disable IPv6 in /etc/postfix/

# See /usr/share/postfix/ for a commented, more complete version


smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost

relayhost = []:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

mynetworks =
inet_interfaces = loopback-only
inet_protocols = ipv4
recipient_delimiter = +

compatibility_level = 2

Create /etc/postfix/sasl_passwd


Then create /etc/postfix/sasl_passwd.db

chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Create /etc/alias.db

postalias /etc/aliases

Restart Postfix

systemctl restart postfix.service


ls -la >/tmp/crap
mail -s "test" < /tmp/crap

Then check output of:

journalctl --no-pager --since=today