I have a postfix server installed on Ubuntu 14.04. A PHP script running on the machine uses it to send outgoing email. Additionally, I use postfix to receive mail sent to a local account, which is then forwarded to my personal gmail.
However, this means that anyone can connect to my server and use it as an open relay for spam. How can I prevent remote connections from relaying email?
This is my main.cf:
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = aviacao.pt virtual_alias_maps = hash:/etc/postfix/virtual alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = aviacao.pt, localhost.localdomain, localhost relayhost = mynetworks = 0.0.0.0/0 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = ipv4
If I change
127.0.0.0/8 then people won't be able to send email to the local account.