Postfix local delivery for certain address, relay for rest?

I have the following situation. The company have a few offices all over the country. They have one hosted email service provider that host thier domain for all offices. Now we have a caching mail server at the largest office, running postfix. IT use fetchmail to download the mail for the people at the office and drop it in local mailboxes. The people then read it from that server via pop3/IMAP. THe email clients also use the caching server to send mail. So local mail is delivered directly and only external mail is relayed outside. The problem now is that mail destined for someone at one of the other branches are bounced by the caching server as no local mailbox exist. (Same domian, so postfix try local delivery) How can I configure postfix to relay mail for those adresses via the external (hosted) mail server? I have been googling and reading posfix docs and so far I have only seen the fallback_relay option, but I set this to the external server, but it still bouces the mails. Any ideas, links, examples please? Thanks -- Andre Truter | Software Consultant | Registered Linux user #185282 Jabber: andre.truter@gmail.com | http://www.trusoft.co.za ~ A dinosaur is a salamander designed to Mil Spec ~

Sun, 27 Aug 2006, by andre.truter@gmail.com: [..]
How can I configure postfix to relay mail for those adresses via the external (hosted) mail server?
I have been googling and reading posfix docs and so far I have only seen the fallback_relay option, but I set this to the external server, but it still bouces the mails.
Any ideas, links, examples please?
Read up on transport(5) Theo -- Theo v. Werkhoven Registered Linux user# 99872 http://counter.li.org ICBM 52 13 26N , 4 29 47E. + ICQ: 277217131 SUSE 9.2 + Jabber: muadib@jabber.xs4all.nl Kernel 2.6.8 + See headers for PGP/GPG info. Claimer: any email I receive will become my property. Disclaimers do not apply.

Andre Truter wrote:
I have the following situation.
The company have a few offices all over the country. They have one hosted email service provider that host thier domain for all offices.
Now we have a caching mail server at the largest office, running postfix. IT use fetchmail to download the mail for the people at the office and drop it in local mailboxes. The people then read it from that server via pop3/IMAP. THe email clients also use the caching server to send mail. So local mail is delivered directly and only external mail is relayed outside.
The problem now is that mail destined for someone at one of the other branches are bounced by the caching server as no local mailbox exist. (Same domian, so postfix try local delivery)
How can I configure postfix to relay mail for those adresses via the external (hosted) mail server?
I have been googling and reading posfix docs and so far I have only seen the fallback_relay option, but I set this to the external server, but it still bouces the mails.
If you're not using an ancient version of Postfix you can route mails depending on the recipient address. /etc/postfix/transport: user@domain.com relay:[ip-of-hostserver] Unfortunately, you haven't provided any helpful configuration details, so I can't tell you if it will work with your configuration. Are you able to relay mails directly to the server that hosts the remote address user@domain.com? If the mails are arriving via pop access to your server, then the server (of your ISP) that accepts the messages in the first place does not know any better. How do you expect the mail in the same domain to reach the other server? Is that server actually able to accept mails directly from the internet? I think the best way to provide reliable mail routing would be to set up subdomains for each office and then rewrite addresses as needed if they relocated. Then the normal mailserver of your ISP would be able to tell where the mail should be delivered to. Sandy -- List replies only please! Please address PMs to: news-reply2 (@) japantest (.) homelinux (.) com

On 8/27/06, Sandy Drobic <suse-linux-e@japantest.homelinux.com> wrote: [...]
If you're not using an ancient version of Postfix you can route mails depending on the recipient address.
/etc/postfix/transport: user@domain.com relay:[ip-of-hostserver]
I'll read up on transport. I think it will work for this situation. Thanks
Unfortunately, you haven't provided any helpful configuration details, so I can't tell you if it will work with your configuration.
Are you able to relay mails directly to the server that hosts the remote address user@domain.com?
Yes. Up to now, each workstation at every office was reading mail directly from the external server and use that as the smtp server also. So the problem is that if Person A sent a mail to Person B, who is sitting just down the corridor, then the mail would go out the ADSL line to the Internet, to the external server and back in through the ADSL line. So, it is double the bandwidth on the ADSL line. With a caching server, sitting at the office, the mail will not go out via the ADSL, saving bandwidth, which is very expensive here in SA.
If the mails are arriving via pop access to your server, then the server (of your ISP) that accepts the messages in the first place does not know any better. How do you expect the mail in the same domain to reach the other server? Is that server actually able to accept mails directly from the internet?
THe office is connected to the Internet via ADSL, so there is not a static IP address. The external server, that hosts all the mailboxes for the whole company sits outside on the Internet, so it can accept mails for the domain, and drop it in POP3 mailboxes. Due to the fact that the offices do not have static IP adresses and that we don't have any control over the external server, we cannot get the external server to forward the mail to the internal server. The internal server have to read the mail from the pop boxes on the external server and then drop it in local boxes for office personnel to read. It is basically set up as a dial-up solution, except that it use ADSL and not Analogue/ISDN to connect to the Internet.
I think the best way to provide reliable mail routing would be to set up subdomains for each office and then rewrite addresses as needed if they relocated. Then the normal mailserver of your ISP would be able to tell where the mail should be delivered to.
That might be a good solution if the client will agree to change all mail adresses and if the ISP is willing to cater for it. I'll look into that too. Thanks -- Andre Truter | Software Consultant | Registered Linux user #185282 Jabber: andre.truter@gmail.com | http://www.trusoft.co.za ~ A dinosaur is a salamander designed to Mil Spec ~

On 8/27/06, Sandy Drobic <suse-linux-e@japantest.homelinux.com> wrote:
If you're not using an ancient version of Postfix you can route mails depending on the recipient address.
/etc/postfix/transport: user@domain.com relay:[ip-of-hostserver]
I tried this, but the server still reply with "User unknown in local recipient table" I am testing it on a SuSE 9.3 box with postfix 2.2.1-3 I read the postfix documentation and it does not mention that the version is too old. I am in the process of setting up a 10.1 test box, as that is the version the production system runs. A bit more info: I am testing with an existing domian that have a mail server on the Internet. lets call it example.com for now (I don't want to list a bunch of valid email adresses as they will get spammed pretty quickly) I have 3 users that I test with: user1@example.com, user2@example.com, user3@example.com. All 3 users can receive mail on the public server. Now I have the test server at home, set up to download and cache mail for user1 and user2. The server have local mail boxes for those two users and client machines on the local network can read teh mail and send mail via the local test server. If user1 send a mail to user2, the server will just deliver it locally. If user 1 send a mail to my gmail account, the local server will relay the mail via the public smtp server, that will deliver it to gmail. So, that all works. Standard caching dial-up local mail server. I added user3 to the transport map: user3@example.com relay:[mail.example.com] (mail.example.com is the public server. local server is mail.test.example.com) So, according the teh transport docs, if user1 on the local server send a mail to user3@example.com, then postfix should relay the mail via mail.example.com. But it does not. What am I missing or misunderstanding? Thanks -- Andre Truter | Software Consultant | Registered Linux user #185282 Jabber: andre.truter@gmail.com | http://www.trusoft.co.za ~ A dinosaur is a salamander designed to Mil Spec ~

Andre Truter wrote:
On 8/27/06, Sandy Drobic <suse-linux-e@japantest.homelinux.com> wrote:
If you're not using an ancient version of Postfix you can route mails depending on the recipient address.
/etc/postfix/transport: user@domain.com relay:[ip-of-hostserver]
I tried this, but the server still reply with "User unknown in local recipient table"
So, WHICH server is giving that error message, the local server or the ISP mailserver? Please show the exact error message. If it is the local server the message indicates that either you have a restriction working that checks if the recipient is valid (reject_unverified_recipient, reject_unlisted_recipient) or the client does not have the permission to relay. The mail can only be routed if it is accepted in the first place. If you have set the domain up in $mydestination, then the lookup for valid recipients in that domain would take place in /etc/passwd and /etc/aliases: local_recipient_maps = unix:passwd.byname $alias_maps The output of "postconf -n" would show the relevant settings.
I am testing it on a SuSE 9.3 box with postfix 2.2.1-3 I read the postfix documentation and it does not mention that the version is too old.
That version is sufficient.
I am in the process of setting up a 10.1 test box, as that is the version the production system runs.
A bit more info:
I am testing with an existing domian that have a mail server on the Internet. lets call it example.com for now (I don't want to list a bunch of valid email adresses as they will get spammed pretty quickly)
I have 3 users that I test with: user1@example.com, user2@example.com, user3@example.com.
All 3 users can receive mail on the public server.
Now I have the test server at home, set up to download and cache mail for user1 and user2. The server have local mail boxes for those two users and client machines on the local network can read teh mail and send mail via the local test server.
If user1 send a mail to user2, the server will just deliver it locally. If user 1 send a mail to my gmail account, the local server will relay the mail via the public smtp server, that will deliver it to gmail.
So, that all works. Standard caching dial-up local mail server.
I added user3 to the transport map:
user3@example.com relay:[mail.example.com]
(mail.example.com is the public server. local server is mail.test.example.com)
So, according the teh transport docs, if user1 on the local server send a mail to user3@example.com, then postfix should relay the mail via mail.example.com.
But it does not.
What am I missing or misunderstanding?
See above. The message has to be accepted first, if postfix should route it externally. Sandy -- List replies only please! Please address PMs to: news-reply2 (@) japantest (.) homelinux (.) com

On 8/27/06, Sandy Drobic <suse-linux-e@japantest.homelinux.com> wrote:
I tried this, but the server still reply with "User unknown in local recipient table"
So, WHICH server is giving that error message, the local server or the ISP mailserver? Please show the exact error message.
It was the local server that gave the error, not the ISP server. In any case, I got it solved. I removed the domain from the "mydestination" option. I just have the defaults in there now. Then I added the email adresses of the local users to the transport map and specified local delivery; user1@example.com local:127.0.0.1 So, now the local server will forward all mail with a domian to teh external server, except for the addresses specified in the transport map. This seems to work fine.
If it is the local server the message indicates that either you have a restriction working that checks if the recipient is valid (reject_unverified_recipient, reject_unlisted_recipient) or the client does not have the permission to relay.
The problem was that the user does not exist on the local server. It only exist on the ISP server. But it seems that if you specify a domain in the list for "mydestination", then postfix will first try to deliver all mail for that domain locally before it checks the transport maps.
The mail can only be routed if it is accepted in the first place. If you have set the domain up in $mydestination, then the lookup for valid recipients in that domain would take place in /etc/passwd and /etc/aliases:
Yip, this is exactly what was happening. The error message was generated because the user does not exist in one of those files, which is correct. So I just looked at things from a different angle and now it works. Thanks -- Andre Truter | Software Consultant | Registered Linux user #185282 Jabber: andre.truter@gmail.com | http://www.trusoft.co.za ~ A dinosaur is a salamander designed to Mil Spec ~
participants (3)
-
Andre Truter
-
Sandy Drobic
-
Theo v. Werkhoven