VirtDomains.pl to Create Virtual Aliases Files for Sendmail

About VirtDomains.pl

Sendmail supports aliases and virtual domain through its aliases map and virtualusertable functions.  However, it is convenient to be able to access an alias file as it were the aliases file directly for one of the virtual domains.  That is what VirtDomains.pl does.

Setup

In sendmail.mc add additional maps for extra aliases file with:

define(`ALIAS_FILE', `/etc/mail/aliases,/etc/mail/alias2')dnl

If you are already using virtusertable for something else then add another virtual user table in sendmail.cf with:

FEATURE(`virtusertable', `sequence v1 v2')dnl

K v2 hash -o /etc/mail/virtusertable.db

K v1 hash -o /etc/mail/virt2.db

Create your aliases in the files in the same name as the domains they represent.  In example-list.com:

root: harry@gmail.com

test1:             "|mailman post test1"

test1-admin:       "|mailman admin test1"

In example.com:

root: dick@gmail.com

To create the proper maps for sendmail execute:

VirtDomain.pl V=/etc/mail/virt2 A=/etc/mail/alias2  /path/to/example-list.com /path/to/example.com

Your /etc/mail/aliases file might have specified root to go somewhere else but if you get mail for root@example-list.com it will go to harry@gmail.com and root@example.com will go to dick@gmail.com.  The test1 address will only be available under the example-list.com domain.

Document Author and Date:

Jim Ziobro / 2018-12-01

Source:

VirtDomain.pl