Link to home
Start Free TrialLog in
Avatar of JAMason1182
JAMason1182Flag for United States of America

asked on

Sendmail - Several local domains delivering to 1 local domain - alias vs. virtusertable

Let's say I own the domains, A.com, B.com, C.com, D.com, E.com and F.com.

Let's also say that our internal networks are listed as Z.local in the internal DNS. Let's also assume that the DNS is perfect... it's not 100% in real life, but the only issues I have are with my ISP and reverse lookups (doesn't affect the mail).

Now, adding to our scenario, let's say that all 6 domains work on the same server. (I just have LOCAL_DOMAIN done for each domain name inside of the sendmail.mc file). The local domain also works by way of the MASQUERADE_AS(A.com).

Now for the fun part. I want to ease the setup involved in adding a user. I use FireTrust's MailWasher server instead of spamassassin because I have to deal with end users who know nothing... they see a button they click it. Thus, I have my mailwasher setup and I have listed the local email address as the main address for each user. Then I added ALL 6 DOMAINS into the list of additional email addresses for each user in MailWasher. THEN, because each of the domains is for a different division in the company (I work in the corporate office, so I have to support essentially 6 different businesses on 1 server... can we say stupid!) anyway... since all 6 domains represent a different division of the company and users are constantly shifting from one company to another to follow a particular project, I have to constantly juggle the domain names/email address combinations to ensure that email comes and goes to an email address at the right domain.

To make it worse, I'm required to setup individual email accounts in thunderbird for each domain... the users want to be able to send under the domain for which they are working at that time.

Sound complicated enough?!? Well that isn't important. What I am looking to do is either put the 6 domains under some virtual domain type setup or possibly under the alias file (is it legal?) so that all users have ONE (1) email address.... their local address. So when an email is received it is brought in and altered so that mailwasher sees the local address, not the particular domain name that was sent to. Also, when an email is sent out, all I have to do is tell the user to select the proper account under thunderbird... even though ALL accounts under thunderbird will be pulling from the local account - they would be separated by what email domain was used for sending.

Hopefully this makes sense.  I've already gotten it to work by removing the LOCAL_DOMAIN macros and putting in the virtual domain file macros - and the virual domain file contains a line for each of A-F.com domains. Then, the only local domain left is the Z.local. But the email comes through as it did before... yous end to user@A.com, the user's local account receives an email with the headers saying user@A.com instead of user@Z.local. If I send to user@B.com, I want to see the header say user@Z.com but instead I see user@B.com.

I'm gonna add more detail to this question in case it isn't clear. If you have an alias called "alien" that is an alias for "dude" then you can send email to alien@domain.com and it will be delivered to "dude@domain.com". The maillog even states "alien is an alias for dude." I want to do the same thing for the DOMAIN side of the (at) symbol. I want to make an alias for dude@domain.com called "alien@another.com". That way in the maillog I will see "alien@another.com is an alias for dude@domain.com" and when I read the header I will see the email was sent to dude@domain.com instead of seeing the alien@another.com.

I guess I really just want to  do to the recipient email address what a router does to an IP packet during NAT translation. I want to see if sendmail can literally alter the header so that the email even goes to the mailwasher milter as the local domain account.

Hopefully that isn't too confusing and I've given enough info. I'm not including my sendmail.mc because as it is right now, it is nothing like I want it to be! So clean slate. Is this sort of "translation" possible... and if so, how do I do it?
SOLUTION
Avatar of razorwoods
razorwoods

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JAMason1182

ASKER

so would I need to replace sendmail with postfix? or would postfix work as a sort of.... first-thing milter?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what is going to be involved in adding postfix on top... meaning can we get into specifics of how to get this behavior setup in postfix?

After reading a little about postfix... it sounds almost like I would be running a different type of sendmail on top of sendmail.... meaning the virtual users table described in sendmail is pretty synonomous to the postfix documentation.... so why would I need to add postfix if sendmail can handle it? ...not shooting you down, but rather wanting to make sure it is the right move.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK... will procmail do it before or after the mail filters are run? Can I get procmail to do it's recipe before the mailwasher milter gets the email? That's where the major simplification is. If I can make it so that all the "alias" domains are changed to the local domain before mailwasher does its scan, then I don't have to add all the domains to every user! It also will give me the framework for our alias scheme... (try doing all 6 domains in the following formats: first.last@domain, f.last@domain, flast@domain.com, last.first@domain.com, etc....) Yes. I agree.  That is a dumb thing to do. But the boss thinks he knows how this should be. He's the one who said "we need a domain name for each company, you we need to make sure that all emails are sent from the proper domain name... blah blah"....

Oh wait, I digress.. so back to this. Can I get procmail to do its thing before the mailwasher milter BUT AFTER clamav? (or before both... but I'd always rather have clamav check it before doing something with it)


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
see I figured it would be something decently simple, such as "add a record for like this to the virtuserstable:
@A.com %1@Z.local
@B.com %1@Z.local
@C.com %1@Z.local
" and then remake sendmail.

Or it would be great if it worked in the alias file altogether! (afterall... aren't the domains All considered "local?") So I guess I'm asking if there is a simple thing like that to help me out.... because the aliases are done before milters (My apache server sends "root" mail and I see the logs say "root is an alias for jamason1182" before I see the clamav, mailwasher, etc. milter output.


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I still don't get, is if i were to use postfix, then when would the user (your example) be just jim-bob?

I'm installing postfix right now.

How do I hook this into sendmail.mc? and do I need to start the postfix service yet? I have lots of questions... please bare with me!
Wow... now that' I'm looking at the main.cf for postfix, I see that it configures similar to samba or clamav....

I'm seeing that I would have the same issues to configure postfix... but the configuration itself might be easier, but confusing.

Let me rephrase that last statement. I don't want to use postfix since I've already got sendmail up and running. I've been tweaking this instance of sendmail for years.  I might as well just get it tweaked the way I want and not lose all my customized settings/defines and features.

The problem isn't difficult... it's a matter of thinking. Define virtual domain vs. local domain. I define virtual as "it isn't really here... but I get mail for it." while a local domain is "It is here and only here. It is 'me'". I have 6 LOCAL domains. The reason why I ask about virtual is the description inside of virtuuserstable for sendmail... it says that I can list any host that's in class {w} or class {VirtHost} and the examples map from 1 domain to another domain. That is why I was asking about the host stuff.

So to revise the question, How best in sendmail, should I manage these 6 domains? And with that I'l talk about more of what i'm doing: A.com is the abbreviated name for B.com. C.com is the abbreviated name for D.com and E.com. F.com is it's own little domain. See the company name for one division is really long... ie "Some Company Name of CityName, Inc."... and so the boss bought "somecompanynameofcityname.com" Dummy. So I bought the name "someco.com" and people are happy with the short one. But all business cards, letterheads, etc. etc. all say the long name. Thus, I want the long one to be the "master" and the little one to be an alias for the big one.

So now that I really think about in a different light... I have four domains: A.com, C.com, and F.com as well as Z.local. I want all my internal stuff to use Z.local. But I want all my external mail to go out as 1 of the 3 (A,C, or F). BUT I have two domain aliases, B.com => A.com, D.com and E.com=>C.com. So, how should I be managing these? Is what I want possible?
Wow... that was tough. OK. Here we go:

First off what I needed wasn't really anything to do with aliases coming IN. After further investigation I needed to make a domaintable file so I could "alias" the domains B.com to A.com, and then from D and E to C.com. So I made a domaintable file, then put this in it:

B.com     A.com
D.com    C.com
E.com     C.com


So that brought the number of domains to worry about down to only A,C,F, and Z.local. So next, I altered my sendmail.mc to include the following:

FEATURE(`domaintable',`hash -T<TMPF> -o /etc/mail/domaintable.db')dnl
FEATURE(genericstable)dnl
GENERICS_DOMAIN(`A.com')dnl
GENERICS_DOMAIN(`B.com')dnl
GENERICS_DOMAIN(`C.com')dnl
GENERICS_DOMAIN(`D.com')dnl
GENERICS_DOMAIN(`E.com')dnl
GENERICS_DOMAIN(`F.com')dnl
GENERICS_DOMAIN(`Z.local')dnl
LOCAL_DOMAIN(`A.com')dnl
LOCAL_DOMAIN(`C.com')dnl
LOCAL_DOMAIN(`F.com')dnl
LOCAL_DOMAIN(`Z.local')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
FEATURE(generics_entire_domain)dnl

Next, I made sure that the virtudomainstable was GONE... since my domainstable maps the B,D, and E to a "local" domain (A,C,F, and Z).

Next, i emptied out my virtual users table (virtusertable) as we didn't need it for that.

So now the kicker: I then made the genericstable file. It looks similar to this

#GENERICSTABLE FILE - kindof like a reverse alias file

jim_bob    jbob@A.com
jbob     jbob@A.com
jim.bob     jbob@A.com

lisa_smith    lsmith@A.com
lsmith    lsmith@A.com
lisa.smith    lsmith@A.com

joe_dunn    jdunn@C.com
jdunn    jdunn@C.com
joe.dunn    jdunn@C.com

# End of Genericstable file

(continued on next post)

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial