How to Set up Sendmail for Virtual Domains

How to Set up Sendmail for Virtual Domains

first of all, i got this by lurking and listening for a long time on the inet-access list, and i also read the o'reilly sendmail book. i finally took the best of all the solutions, and implemented this.

secondly, while the docs now strongly suggest that you maintain the m4 macro files provided, and let them build your sendmail.cf, i have already learned and configured the sendmail.cf directly, so you may want to figure out how to apply these configuration changes to the m4 stuff.

well, here goes:

1) it is assumed at this point that you have a domain registered with the internic, with the proper dns entries, including the mx, and secondary dns arranged somewhere. let's assume virtdomain.com for any examples here, with the original domain as mydomain.com.

2) make an entry in the /etc/sendmail.cw file to tell sendmail to accept mail for this domain:

virtdomain.com

3) configure a file for the virtual host domains, and one for the return mail masqs. virtualhosts.db will hold the descriptions of how to deliver mail to the virtual domain(s). virtualmasqs.db will hold descriptions of how to re-write users' return addresses to the virtual host, so they don't even have to re-configure their mail clients. to do this, add the following 2 lines to the sendmail.cf file, just after the Cw /etc/sendmail.cw entry:

Kvirtualhosts btree /etc/virtualhosts.db Kvirtualmasqs btree /etc/virtualmasqs.db

4) add the following rule set 40 for the return mail masq:

S40

R$* < @ $* > $*[tab]$@ $1 < @ $2 > $3[tab]already fully qualified
#bc instead of automatically using $M, lookup masquerade in virtualmasqs
R$*[tab]$: $(virtualmasqs $1 $: $1 @ $M $)
#bcR$*[tab]$: $1 @ $M[tab]add local qualification
R$* @[tab]$: $1 @ $j[tab]if $M not defined

5) add the following rule set 98 for the virtual hosts:

S98

#################################
# new stuff for virtual domains #
#################################

R$+ < @ $+ . >[tab]$: $1 < @ $2 > .
R$+ < @ $+ > $*[tab]$: $(virtualhosts $1@$2 $: $1 < @ $2 > $3 $)
R$+ < @ $+ > $*[tab]$: $(virtualhosts $2 $: $1 < @ $2 > $3 $)
R$+ < @ $* > . [tab]$: $1 < @ $2 . >

5) create /etc/virtualhosts with your favorite text editor:

virtdomain.com frank@mydomain.com
gloria@virtdomain.com gloria@mydomain.com
webmaster@virtdomain.com fred@someother.domain.com

6) create the database virtualhosts.db from virtualhosts with the makemap command (makemap comes with sendmail):

makemap btree virtualhosts.db < virtualhosts

7) create /etc/virtualmasqs:

frank frank@virtdomain.com
gloria gloria@virtdomain.com
fred fred@virtdomain.com

8) create the database virtualmasqs.db from virtualmasqs with the makemap command (makemap comes with sendmail):

makemap btree virtualmasqs.db < virtualmasqs

9) since the sendmail.cf file was modified/recreated, you must kill sendmail and re-start it.

finis) your configuration should be finished and functional. from now on, whenever you create new virtual hosts, you only need to add the appropriate lines to the virtualhosts and virtualmasqs files and re-make the databases.

hope this is helpful! &*)

cheers,
jeff

PS:

if you have any questions or comments reguarding mail setup for virtual domains, please feel free to e-mail me at: jeffrl@wantabe.com

Copyright © 1995,1996, Wantabe, Inc.
1916 total hits since Thursday August 15. 6 hits today.
Last access on Saturday November 15 at 16:13:49 from msql.wantabe.com
Page was last updated on Wednesday November 13, 1996 at 12:19:19