Score:0

Postfix test: I can't forwarding outgoing emails

br flag

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
ca flag
seems clear the problem is the invalid regexp in /etc/postfix/redirect
Score:0
jp flag

You are trying to use a regexp with a negative lookahead (?!) with a regexp map which doesn't support that. You need to replace regexp: with pcre:

br flag
It gets better. But despite redirecting to the maildrop address nothing is going on. Secondly, the local messages are also redirected to the mail drop and I would prefer that they simply reach the local accounts.
jp flag
Your regexp specifies that all domains except `hostname\.localdomain` are going to be redirected into `mailtrap` but your configuration specifies `mail1.test` as a local domain.
br flag
Yes, I changed the notation : /.*@(?!mail1\.test$).*/ mailtrap According to the logs, everything goes where it should, but the mailtrap account is empty
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.