1

Been try to find a similar setup like this but cannot find it or simply don't know exactly what to search for.

Scenario: we just took over abc.com email operations, but there is still another server that handles a few accounts for that domain as well. MX now points to us, but if we don't have the user with that domain here, we still want to try delivering the mail to the old server, and it can bounce the mail if the recipient doesn't exist.

Steps would be:

Email comes in, check if the domain is something we handle otherwise reject.

Check if the email address exists in LDAP, if it does, send email to a specified mail server.

If it doesn't exist in LDAP, check secondary file for domain specific server to send that mail to.

If it doesn't exist in LDAP and the domain is not specified in the secondary file, bounce it.

I am using mydestination for domain checking and alias_maps for ldap lookup, both work.

Is this possible with Postfix?

3
  • This step (If it doesn't exist in LDAP and the domain is not specified in the secondary file, bounce it.)is not necessary as it is done in 1st step itself. And yes it is doable in postfix
    – clement
    Apr 4, 2014 at 8:30
  • Can you elaborate please?
    – luthan
    Apr 7, 2014 at 14:39
  • This is very useful, when you must migrate some users to different server. Oct 6, 2022 at 7:34

1 Answer 1

2

Add abc.com to mydestination and set local_recipient_maps to be empty (to disable recipient validation) in your main.cf. Assume [email protected] is in your server and [email protected] is in remoteabc.com

#/etc/postfix/main.cf
#...
mydestination = $myhostname, localhost.$mydomain, localhost abc.com 
local_recipient_maps =
transport_maps = hash:/etc/postfix/trans
alias_maps = hash:/etc/aliases
#...
#/etc/postfix/trans
#...
[email protected] local: 
[email protected] local: 
# send all other user mails to remote server
abc.com smtp:remoteabc.com:25
#...
#/etc/aliases
userhere:         some_unix_user

Here hash lookup table is used for transport_maps. You can use any lookup type of your choice. Hope that helps.

4
  • Thank you for writing this up. The issue I have is that I don't know exactly what addresses the remote server might have. Hence, I cannot specify email addresses in the trans file. Only domains. If [email protected] doesn't exist in LDAP, but I have a file that contains "abc.com smtp:someremoteserver:25", then instead of NDR, send the message to someremoteserver. Hopefully that makes sense.
    – luthan
    Apr 9, 2014 at 15:38
  • Updated the answer.
    – clement
    Apr 10, 2014 at 17:49
  • Feel terrible to keep bugging you, but there is still another issue. Since my valid users that are on our network are looked up with LDAP, there is no way for me to specify where to send emails to those addresses, unless there is a way to specify it in ldap-aliases.cf that I am using. ldap-aliases.cf simply contains the ldap server name, and specifies how to find the valid emails. It is called by alias_maps in main.cf
    – luthan
    Apr 10, 2014 at 21:24
  • Just create a simple script that can return local: for users existing in LDAP and smtp:remoteabc.com:25 for the rest. Use tcp tables lookup type to plug it with postfix. This page should help you to understand how to use tcp table lookup type kutukupret.com/2010/12/06/…
    – clement
    Apr 11, 2014 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .