2

I have a mail server that accept emails from any domain. This is accomplished by using the following line in Postfix's main.cf:

mydestination = regexp:/etc/postfix/mydestinations.reg

and mydestinations.reg looks like this:

/^.*/                           OK

Now, I want to forward emails to a specific user (e.g. to admin) to an external email address. I added the following line to /etc/aliases

admin: email@externaldomain.com

After running newaliases and sending an email to admin the rule is met, but Postfix tries to deliver the email locally instead of remotely. That leads to the following error message in the Postfix log:

status=bounced (unknown user: "email")

My guess is, that Postfix assumes that externaldomain.com is in its destination since it is configured to accept any domains.

Now my question: How can I tell Postfix to forward the email to the external domain while keeping the catchall mydestination intact?
Side note: I would like to avoid using virtual aliases if possible.

  • You can also modify the regex to exclude the specified domain, would be the simplest solution I think. – sebix Apr 24 '15 at 20:41
5

My guess is, that Postfix assumes that externaldomain.com is in its destination since it is configured to accept any domains.

Yep, it's true

Now my question: How can I tell Postfix to forward the email to the external domain while keeping the catchall mydestination intact?

To override next-hop lookup from postfix, you need to define entry in transport_maps for every external address used in alias.

# main.cf
transport_maps = hash:/etc/postfix/externaladdr

# /etc/postfix/externaladdr
email@externaldomain.com  smtp:externaldomain.com

With this entry smtp:externaldomain.com, postfix will try to send email with smtp transport to the mail server of externaldomain.com.

  • Thanks for your answer. I tried your solution. However, all incoming emails seem to bounce now: warning: hash:/etc/postfix/externaladdr is unavailable. open database /etc/postfix/externaladdr.db: No such file or directory and warning: hash:/etc/postfix/externaladdr lookup error for "incoming@domain.com" and warning: transport_maps lookup failure which leads to the bounce NOQUEUE: reject: [...] Temporary lookup failure;. I created the file /etc/postfix/externaladdr exactly like you said and added the line to main.cf – horen Apr 20 '15 at 9:35
  • My bad, I omit the important step, postmap /etc/postfix/externaladdr. And don't forget to run postfix reload – masegaloeh Apr 20 '15 at 9:39
  • Yep. the postmap was the problem. Now it's working fine. Thanks! – horen Apr 20 '15 at 9:43

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.