Sendmail : Mail delivery of same domain to internal or external mail server

sendmail

Its bit difficult to explain but very simple problem.

We have internal sendmail server and hosted server. Both are set to same domain name. We have mixed mail accounts.

For example we have two user in one office.
a@abc.com is local only
b@abc.com is internal plus external.

Internal means we create user on local linux box where sendmail is set.

External means we create user on local and hosted server.

a@abc.com can send mails to any internal user created on Linux box where sendmail is installed. But he can not send mail to outside domain and no mail can be sent to him as there is no account created on external hosted server.

b@abc.com can send mails to internal as well as all other domains through sendmail's smart_host feature, which uses hosted server's smtp.
b@abc.com can get all external emails internally through Fetchmail on linux box.

Now we have third user c@abc.com who will be always outstation and can use external server only.

So I can not create account on local linux box for c@abc.com because his mail will get delivered locally only.
I don't want to create alias and send his mails to gmail or yahoo's account. I want to send emails to his external account from any internal user.

How this can be done? Thanks in advance.

Best Answer

For the delivery part of email destined for one of these users you can use the "virtusertable" feature. To redirect the email of only some users to an external address, e.g. for your sample users you could add this to your sendmail.mc file:

FEATURE(virtusertable, `hash -o /etc/mail/virtusertable')

Then in the /etc/mail/virtusertable file use something like this to deliver email for a@abc.com locally, and email for b@abc.com or @c@abc.com* to the remote, hosted server:

a@abc.com localuser

b@abc.com b@hosted.server

c@abc.com somebody@hosted.server

Rebuild the virtusertable.db map by running makemap(1), and Sendmail should be able to handle the delivery part of email ok:

# cd /etc/mail

# makemap hash virtusertable < virtusertable

Controlling which local user is allowed to send email is slightly more involved. You might be able to use "relay_mail_from" and access map entries, but since I haven't actually tried this, I'll let someone else answer with more useful details.