Saturday, September 26, 2009

SENDMAIL Notes 11: Sendmail Virtual Domains & Vitual Users

Basic Virtual Domains

    Sendmail allows to host multiple domains in single instance. The Basic Virtual Domain can be created using local-host-name file. When sendmail receives mail, it needs a way of determining whether it is responsible for the mail it receives. It uses the /etc/mail/local-host-names file to do this. This file has a list of hostnames and domains for which sendmail responsible for mail.
For example, if this mail server was to accept mail for the domains and then the file would look like this:

# cat  /etc/mail/local-host-names

In this case, remember to modify the MX record of the DNS zonefile point to Here is an example (Remember each "." is important): MX 10

    So if we send mail to the user "user1" for both the domain ( &,because of the MX record pointed the mail will reach the same server and as we have configured the local-host-name file sendmail will accept the mail for both the domains. The mail will be delivered to the same user user1 which is a local user.
    The mail server will default acceptance of mail for its FQDN defined without the entry in local-host-names.

Virtual users and virtual domains:

    This is defined using the virtual user table feature in sendmail configuration.The file used is virtusertable in /etc/mail. While defining the virtusertable the domain name should not exist in local-host-names.
    The /etc/mail/virtusertable file contains a set of simple instructions on what to do with received mail. The first column lists the target email address and the second column lists the local user's mail box, a remote email address, or a mailing list entry in the /etc/aliases file to which the email should be forwarded.
If there is no match in the virtusertable file, sendmail checks for the full email address in the /etc/aliases file.

Defining the virtual domains and users (Keep in mind that the exact MX record has been added to respective domains):

VIRTUSER_DOMAIN_FILE(`-o /etc/mail/virtuserdomain')dnl

    FEATURE(`virtusertable')dnl expects to existance of the database  vrtusertable in /etc/mail.
    VIRTUSER_DOMAIN_FILE(`-o /etc/mail/virtuserdomain') it looks up the various domains that supported by sendmail in this given path.

#compile configuration and restart the sendmail service

Now create the virtuserdomain file - this will tell the sendmail a list of domains that sendmail has to recieve mails

#edit /etc/mail/virtuserdomain

Now create the virtusertable database - it contains the mapping of virtual users/domains to mail box or remote mail box

#create/edit    /etc/mail/virtusertable        kiran@someotherdomain        jithu

#makemap hash virtusertable < virtusertable

#Now restart the sendmail service

    Now if we sendmail to from anywhere it will be redirected to kiran@someotherdomain and mail send to will be send to the local mail box of user jithu.

Other options in virtusertable:    jithu    kiran

    This will redirect all the mails that came to to user jithu, and all the mails send to domain to local user kiran. Any mail comes to will be redirected to

No comments:

Post a Comment

tag ur valuable ideas below