Email notes
Bouncing unwanted spamEdit
Edit Postfix configurationEdit
Open /etc/postfix/main.cf with your favourite editor:
sudo nano /etc/postfix/main.cf
Find the line beginning with:
smtpd_recipient_restrictions =
If it doesn’t exist, you can add one near the end of the file. Add this rule near the top of that list (before other entries)
check_sender_access hash:/etc/postfix/sender_access,
It should look something like:
smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/sender_access, permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
2. Create the sender access mapEdit
Create or edit the file
sudo /etc/postfix/sender_access
Add an entry for the sender you want to reject. Example:
spam@example.com 550 5.1.1 User not known here
You can also block entire domains if you prefer:
example.com 550 5.1.1 User not known here
3. Build the lookup databaseEdit
Run:
sudo postmap /etc/postfix/sender_access
This creates the corresponding
/etc/postfix/sender_access.db
4. Reload PostfixEdit
Apply the changes:
sudo systemctl reload postfix
5. Test itEdit
From an external email account, try sending a message from that blocked address.
You should see in your Postfix logs
/var/log/mail.log
something like:
NOQUEUE: reject: RCPT from mail.example.com[1.2.3.4]: 550 5.1.1 User not known here; from=<spam@example.com>
The sending server receives a permanent bounce (5xx), so it stops trying.