How Can We Help?
Postfix SMTP forwarder
sudo apt update sudo apt upgrade sudo apt install mailutils sudo apt install libsasl2-modules
sudo nano /etc/postfix/main.cf
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = myserver.domain.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = $myhostname, myserver.domain.com, malfurion,localhost.localdomain, localhost relayhost = [mail.isp.server.com]:587 mynetworks = 127.0.0.0/8 192.168.0.0/16 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all # enable SASL authentication smtp_sasl_auth_enable = yes # disallow methods that allow anonymous authentication. smtp_sasl_security_options = noanonymous # where to find sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
We have configured the postfix instance to accept mail from the ‘mynetworks’ variable on port tcp/25 and forward it to the ‘relayhost’ variable which is the upstream ISPs secure SMTP server (on port 587). Because we are using secure smtp we need to set the sasl variables which is basically the username and password to use for each connection to the secure upstream mail server.
sudo nano /etc/postfix/sasl_passwd [mail.isp.server.com]:587 username@domain.com:password sudo postmap /etc/postfix/sasl_passwd sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db sudo service postfix restart sudo service postfix status
echo "Test email fwd" | mail -s "Mail fwd from Postfix - your.servers.dns.name" -a "From: mailfwd@domain.com"externalperson@domain2.com tail -f /var/log/mail.log