Solved

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

Posted on 2008-10-13
14
633 Views
Last Modified: 2013-12-18
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?
0
Comment
Question by:JAMason1182
  • 9
  • 5
14 Comments
 
LVL 3

Assisted Solution

by:razorwoods
razorwoods earned 500 total points
Comment Utility
Are you doing all of this manually in Sendmail itself ?

Postfix does all the things you mentioned above and it's pretty easy to manage, even at the command line.

0
 

Author Comment

by:JAMason1182
Comment Utility
so would I need to replace sendmail with postfix? or would postfix work as a sort of.... first-thing milter?
0
 
LVL 3

Assisted Solution

by:razorwoods
razorwoods earned 500 total points
Comment Utility
You run it on top of sendmail.  If you're on Debian its as easy as ' apt-get install postfix ' and if you're on CentOS , Fidora, or RedHat it's ' yum install postfix '

You'll want to read the docs first just to be sure it's what you want.

http://www.postfix.org/documentation.html

0
 

Author Comment

by:JAMason1182
Comment Utility
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?

0
 

Author Comment

by:JAMason1182
Comment Utility
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.
0
 
LVL 3

Assisted Solution

by:razorwoods
razorwoods earned 500 total points
Comment Utility
Sendmail will do that things you're trying to do, but from reading your question it seemed like you wanted to do the sames thing in an easier way.  Postfix is much easier to manage virtual users and alias domains in my opinion.


Lay that up with procmail for some per user recipes on mail handling ... that's an option.


0
 

Author Comment

by:JAMason1182
Comment Utility
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)


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Assisted Solution

by:razorwoods
razorwoods earned 500 total points
Comment Utility
I believe the order in which anything processes is specified in the sendmail cf file isn't it ?

The more direct way to do this might just be to write a shell script that accepts a single argument such as frank.jones and then creates your user and updates virtual users with all the variations.

Then you'll have your existing (working) system and a way to easily get new users in and even may out.

0
 

Author Comment

by:JAMason1182
Comment Utility
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.


0
 
LVL 3

Assisted Solution

by:razorwoods
razorwoods earned 500 total points
Comment Utility
Again, this is why I like Postfix.  In the virtual table all domains are local as long as you put in the statement.

This would literally be your virtual user file for 3 domains and the user Jim Bob following your rough examples.

I was able to type this out in about 30 seconds.  It's very flexible.

ie.  

a.com                virtual
b.com                virtual
c.com                virtual

jim.bob@a.com  jim-bob
j.bob@a.com      jim-bob
jim.b@a.com      jim-bob
jim.bob@b.com  jim-bob
j.bob@b.com      jim-bob
jim.b@b.com      jim-bob
jim.bob@c.com  jim-bob
j.bob@c.com      jim-bob
jim.b@c.com      jim-bob

0
 

Author Comment

by:JAMason1182
Comment Utility
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!
0
 

Author Comment

by:JAMason1182
Comment Utility
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?
0
 

Author Comment

by:JAMason1182
Comment Utility
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)

0
 

Accepted Solution

by:
JAMason1182 earned 0 total points
Comment Utility
(continued from previously)
So now... 2 scendarios.
 1) Someone wants to send mail to Jim Bob and they send to jim_bob@A.com, jim_bob@B.com, jbob@A.com, jbob@B.com, jim.bob@A.com or jim.bob@B.com => The domaintable maps all the B.com entries to A.com entries and the normal alias file translates jim_bob, jbob, and jim.bob to just jbob (the local username). Bingo.

Similarly if someone wants to send mail to Joe Dunn, they can send to jdunn@C.com, jdunn@D.com, jdunn@E.com or joe_dunn or joe.dunn at any of those three .coms.

2) But what about joe dunn!? What if he sets up his own IMAP account that will make a connection to the mail server to send mail out and he puts his email ass joe_dunn@E.com? Number one, joe_dunn, though in the alias file... isn't an alias in the FROM address! So assuming he passes the AUTH part of sendmail.... his email will go out FROM joe_dunn@E.com... right?! Nope. The genericstable lists the "reverse aliases" for joe. And the macro GENERIC_DOMAIN listings in sendmail.mc mean that each domain listed there will be passed through to find user matches in the genericstable. So no matter which joe sends out as: joe_dunn@E.com, jdunn@D.com, whaterver, it will be mapped to the user jdunn@C.com sending it out.

This also works in the event an employee moves from one department to another. So if joe_dunn gets moved from the F department to the A department, all I have to do is change his genericstable entry to mapp to jdunn@A.com and ALL mail will go there. Even if he sends out as jdunn@Z.local or jdunn@F.com. It will all be mapped.


This is the sort of thing I wanted. Now all I have to play with is the darn order of milters and some antivirus / antispam stuff and things are perfect!

razorwoods was the one to help me. So I'm giving you the points.

0

Featured Post

Want to promote your upcoming event?

Are you going to an event? Are you going to be exhibiting at a tradeshow? Talking at a conference? Using a promotional banner in your email signature ensures that your organization’s most important contacts stay in the know and can potentially spread the word about the event.

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Easy CSR creation in Exchange 2007,2010 and 2013
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now