I am configuring a Postfix server in a test environment. It can only forward local emails. Outbound email must be redirected to /dev/null or to a local account. I found a solution on your forum but it unfortunately does not work properly.
I do not have much experience with Postfix. Please help me.
/etc/postfix/main.cfg
compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = all
inet_protocols = all
myhostname = host.mail1.test
mydomain = mail1.test
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, $mydomain
mynetworks_style = subnet
relay_domains = [mail1.test]:587
smtpd_client_restrictions = permit_mynetworks
smtpd_helo_restrictions = permit_mynetworks
smtpd_sender_restrictions = permit_mynetworks
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject
header_checks = regexp:/etc/postfix/header_checks
virtual_alias_maps = regexp:/etc/postfix/redirect
/etc/postfix/redirect
/.*@(?!hostname\.localdomain$).*/ mailtrap
/var/log/maillog
Jan 3 12:32:17 mail1-test postfix/trivial-rewrite[49647]: warning: regexp map /etc/postfix/redirect, line 1: Invalid preceding regular expression
Jan 3 12:32:17 mail1-test postfix/cleanup[49648]: warning: regexp map /etc/postfix/redirect, line 1: Invalid preceding regular expression