Sasha's Pages: Tech: Sendmail Virtual Hosts
Send comments/suggestions to sasha@forum.swarthmore.edu.
Introduction.

This page contains information on how to configure Sendmail for virtual hosts on UN*X.

Relevant or useful links.

Configuration.


Version		Sendmail 8.9.X
OS		Any UN*X OS (including Linux, Digital UNIX, etc.)

Summary.

Accepting incoming VH mail: Sendmail can be configured to accept mail 
			    addressed to virtual domain users, and deliver
			    such mail to local recepients. 
			    

Rewriting outgoing VH mail: Sendmail also allows rewriting outgoing mail (originating from local users) as if it it were coming from a different domain. This way, sasha@forum.swarthmore.edu can be rewritten as sasha@mathlinks.com.

Putting it all together.

Here are step-by-step instructions:

CONFIGURING SENDMAIL TO ACCEPT MAIL FOR VIRTUAL DOMAINS/HOSTS

  1. Build and install makemap (part of sendmail distribution). Makemap is necessary to create a hash table of users.

  2. Edit /etc/sendmail.cw to add the new domain name[s] (so that the mail server knows to handle incoming mail for the new domain[s]).

  3. Create /etc/virtusertable text file containing mail aliases:

    		[username]@newdomainname LOCAL_USER (or remote user elsewhere) 
    	     

    where [username] is optional. If USERNAME is omitted, all mail coming to NEWDOMAINNAME will be delivered to the specified person.

  4. Create a new hash table of aliases:

      		makemap hash /etc/virtusertable < /etc/virtusertable
    	

    which will create /etc/virtusertable.db database file.

  5. Add the following line to your Sendmail M4 configuration file, SITE_CONFIG.mc:

      		FEATURE(virtusertable)  
    	

  6. Generate a new sendmail.cf file:

      		m4 ../m4/cf.m4 SITE_CONFIG.mc > SITE_CONFIG.cf
    	
    Back up the current /etc/sendmail.cf and copy your newly created SITE_CONFIG.cf to /etc/sendmail.cf. Then restart sendmail.

CONFIGURING SENDMAIL TO REWRITE OUTGOING MAIL FOR VIRTUAL DOMAINS/HOSTS

  1. Add the following lines to the sendmail.mc file:

    	     	FEATURE(masquerade_envelope)
    	     	FEATURE(genericstable, `hash -o /etc/genericstable')
    	     	GENERICS_DOMAIN_FILE(`/etc/sendmail.cG')
    	

    The first line will ensure that not only the message headers (From:) will be rewritten, but also the message envelope (Return-to:).

  2. Generate a new sendmail.cf file.

  3. Create /etc/genericstable textfile containing local users mapped to desired addresses:

    	     	sasha        sasha@mathlinks.com
    	     	peter        peterthegreat@mathlinks.com
    	

  4. Run "makemap hash /etc/genericstable < /etc/genericstable" to create a hash database to be used by Sendmail.

  5. Create /etc/sendmail.cG containing the fully qualified name of the _LOCAL_ mail server. In our case, it would be forum: forum.swarthmore.edu.

  6. Restart sendmail.