0

I just installed PostFix on Cent OS 7. I want to set up mail forwarding from an admin address to my Gmail account but I also want to block all emails that are sent to emails that are not addressed to that admin account. At the bottom of my /etc/postfix/main.cf file, I have

virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual

transport_maps = hash:/etc/postfix/transport

From that same machine, if I send this email, its not received

echo "This is the body of the email" | mail -s "admin line 2" admin@example.com

However, if I comment out the last line above (the "transport_maps = hash:/etc/postfix/transport" line), then the email goes through. How do I block emails sent to other domains but also keep my forwarding in place? The /etc/postfix/virtual file contains

admin@example.com myemail@gmail.com

and the file /etc/postfix/transport contains

example.com    :
*              discard:
0

Instead of doing this in transport, look at the recipient list

In main.cf

smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access

in /etc/postfix/recipient_access

admin@example.com OK
* DISCARD

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.