LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Build a mail box for internal and external mail (http://www.linuxquestions.org/questions/linux-server-73/build-a-mail-box-for-internal-and-external-mail-588172/)

Corsari 09-29-2007 04:11 AM

Build a mail box for internal and external mail
 
Dear friends, I'm not a guru and until now I had setup some small servers to provide internal only mail system (mail systems... seems huge but they where just 3 to 6 internal mails eheheh)

I have a nice issue to submit you. I think it is a classical application, but I can't find the right how to or documentation. So welcome if you have any.

The scenario is a damn small lan with 6 clients and 6 mail addresses hosted by an external provider. Mail accounts are joe.smith@external.it james.iron@external.it info@external.it etc

The goal is to start a linux box that will allow them to:
- have JUST ONE AND ONLY MAIL ACCOUNT in each mail client
- make the mail traffic from/to theirself addresses to travel through their LAN only and not to go outside the LAN to the external.it server to next come back.

My first question is: if the linux server will be linux.box and linux users may be joe, james (just the name) while the provider is external.it with mailboxes joe.smith@external.it, james.iron@external.it... are (with postfix) the virtual and sender_canonical files the right tools to manage this?

If yes, what will be changed in the whole system to make it work?
I suppose that LAN mail clients would be changed according to linux box configuration like joe@linux.box, james@linux.box and later the linux box will be the one that manages the mail between inside or outside doing appropriate changes to the mail. Isn't it?

Which part will or would be done by fetchmail and procmail?

Anyway, thank you for reading and much more thank you if you give me the direction on what to work on. Better than better thank you very much if you have a link with a documentation for such configuration.

Regards

Robert

.

Berhanie 09-29-2007 07:59 AM

Hi, Corsari.


The postfix site has excellent documentation. This one describes running postfix in various situations. This is a good place to start.

Corsari 09-29-2007 08:36 AM

Quote:

Originally Posted by Berhanie (Post 2907441)
... postfix site has excellent documentation. This one describes running postfix in various situations. This is a good place to start.

Hi Berhanie, thank you for your suggestion, sometime we forget about official websites.

But allow me to remind you I'm not a guru and so, I'm searching for something that sounds much more like an help or some tutorials that points out my described situation, that I believe is a classical one.

I'm not good in english expecially in this technical english. As example, how do you call the configuration I prospected?

Do you think is available on the postfix documentation you kindly linked to me? As example i have found this, but is this my situation?. Thank you for any help and suggestion.

Robert

.

Berhanie 09-29-2007 12:27 PM

I think your situation is described here.

fetchmail is the kind of program you'd use to download mail from your ISP and store it on your local machine.

Regarding the Postfix variables you mentioned, the generic maps is what you'd use to translate sender addresses in outgoing mail from the local form (user@linux.box) to the external form, as you can see by reading the link. For the reverse direction, to translate external addresses to internal ones, you have a choice: You could have Postfix do the translation with virtual maps (virtual_alias_maps), or you could configure fetchmail to do it. The situation may be more complicated if all your external email addresses are stored in a single mailbox by your ISP.

Corsari 09-30-2007 11:02 AM

Quote:

Originally Posted by Berhanie (Post 2907648)
I think your situation is described here....

Thank you Berhanie, now the scenario became more sharper to me.

I'm still confused about what I understand is called the relaying from my server to the ISP server just 'cause I don't have much clear "what" is that logins to the ISP server and forwards the to-be-sent-to-the-internet emails to it

Anyway, reading what you kindly linked seems to confirm my supposition:
all the office clients must be changed from isp_Account_Name@external.it to linux_box_login(or alias)@linux.box. Isn't it? This will force internal mail to travel inside the LAN and only foreign addresses to be delivered through the internet.
About your opinion, does it exist a more professional solution to overcome all this outlook/thunderbird accounts swapping? Let say playing with configuration files and linux box name and domain name? I think not, but thank you if you confirm it to me.

Quote:

Originally Posted by Berhanie (Post 2907648)
fetchmail is the kind of program you'd use to download mail from your ISP and store it on your local machine...

Maybe it is better me to start playing a bit on/with a real server, but please, as asked above... I have clear where I have to setup mail account login and password for mail downloading: fetchmail. But what about mail sending? Or better to say, mail relaying?

I mean that we have postfix that can delivery in various method. For many reasons I'd like postfix to send mail through the ISP's smtp server and not to deliver directly the mails.
this mainly because I've seen some antispam systems that compares domain's IP with real sender IP and if don't matching, they mark it as spam. What do you think about this?

Anyway thank you for your time, your answers and help, and thank you in advance for any other.

R.

.

Corsari 10-01-2007 01:10 PM

Ok, I Got It Working - Yeeeeeh!!!
 
@ Berhanie:

dear Ber, I really thank you for your support and suggestions.

Only one question for you.

Quote:

preface: I'm using a user which name is test3. So, local mail is test3@linux.box, my external account is robert.c@provider.it, relayhost has been setup with provider.it smtp ip address between [], like [xxx.yyy.zzz.jjj]
About your opinion: why I've got it working only with generic and not with canonical file/db?

now main.cf content has been added of the following lines
Code:

smtp_generic_maps = hash:/etc/postfix/generic
virtual_alias_maps = hash:/etc/postfix/virtual
canonical_maps = hash:/etc/postfix/canonical

This is the setup in the canonical file (enabled by the postmap command)
Code:

test3 robert.c@provider.it
This is the setup in the virtual file (enabled by the postmap command)
Code:

robert.c@provider.it test3
This is the setup in the generic file (enabled by the postmap command)
Code:

test3@fm3.box robert.c@provider.it
I supposed it would have work with canonical while it is not...

Anyway thank you.

Robert

.

Berhanie 10-01-2007 06:44 PM

Hi,Corsari.

You'll have to track this thing down step-by-step.
First thing you need to read and understand is how addresses are rewritten here.

Here's how to procede:

I. Address rewriting when mail is received:

When you submit mail to user test3, the address is rewritten as test3@$myorigin. After that, it hits canonical (make sure virtual doesn't undo later what canonical does now). Our canonical table says to do this: test3 -> robert.c@provider.it, which according to the canonical man page ("man 5 canonical") and after some simplification, is equivalent to: test3@$myorigin -> robert.c@provider.it. This means the address gets rewritten to robert.c@provider.it. Finally, virtual aliasing takes place; so, our case, unfortunately, the address is written back to the test3 which ("man 5 virtual") ends up as test3@myorigin. At this point the mail enters the incoming queue.

II. Address rewriting when mail is delivered:


At this point, the mail is classified into local or remote. Local domains are listed under $mydestination, and are delivered locally. The value of $myorigin is a local address (probably), so test3@$myorigin is delivered locally. If the address were not local, and if it the mail were to leave the machine for its destination via smtp, then it would be subject to the generic mapping.

Corsari 10-02-2007 01:45 AM

Quote:

Originally Posted by Berhanie (Post 2909830)
Hi,Corsari.

You'll have to track this thing down step-by-step.
First thing you need to read and understand is how addresses are rewritten here.

Here's how to procede:

I. Address rewriting when mail is received:

...

II. Address rewriting when mail is delivered:


...

I supposed canonical to be involved in delivery... I must read with more attention.
As said above, with generic it does work fine.

One question about generic DB itself. In this way it gets populated by my manual entries. But, one curiosity, what if I were in a company with 100 users... 100 manual entries? Or do we have one more professional approach available?

Thank you always Berhanie for your time.

R.

Berhanie 10-02-2007 07:20 PM

It just goes to show, you don't have to use virtual. There are other ways.

For a large number of users, you could write a script to populate various tables. You might also find postfixadmin useful at some point.

robert@fastec 11-12-2007 05:50 AM

Thank you for this thread

it was what I was searching for.

Robert

.


All times are GMT -5. The time now is 11:40 AM.