/etc/aliases vs virtusertable

Key differences between virtusertable and aliases in sendmail

virtusertable provides one to one mapping of recipient address. aliases provide one to many mapping (handy for mailing lists).

aliases map "domain-less" recipient (recipients in local email domains with stripped domain part of email). virtusertable maps full recipient address.

virtusertable handles remapping of "all other/remaining addresses in email domain".

"virtusertable to alias" mapping may be used to get one to many mapping.


Wizard level hint: It is possible to make sendmail.cf handle aliases for full emails (user part and domain) but sendmail.cf generated using m4 files provided by sendmail.org does not handle it. Implementing it will not be very complicated but IMHO some unexpected "side effects" are guaranteed => proper testing period will be LONG.


Short Answer:

Aliasing is the process of converting one local recipient name on the system into another and Aliasing occurs only on local names. Which means, the username must be available via getpwnam from the password database:

e.g., the local password file /etc/passwd, NIS, and LDAP.

The sendmail virtusertable feature enables support for the virtual users, meaning it maps non-system users.


I have quoted the following from here. Very well explained, please have look.

/etc/mail/aliases

This database file contains a list of virtual mailboxes that are expanded to users, files, programs, or other aliases. Here are a few entries to illustrate the file format:

root: localuser
ftp-bugs: joe,eric,paul
bit.bucket:  /dev/null
procmail: "|/usr/local/bin/procmail"

The mailbox name on the left side of the colon is expanded to the target(s) on the right. The first entry expands the root mailbox to the localuser mailbox, which is then looked up in the /etc/mail/aliases database. If no match is found, the message is delivered to localuser. The second entry shows a mail list. Mail to ftp-bugs is expanded to the three local mailboxes joe, eric, and paul. A remote mailbox could be specified as [email protected]. The third entry shows how to write mail to a file, in this case /dev/null. The last entry demonstrates how to send mail to a program, /usr/local/bin/procmail, through a UNIX® pipe. Refer to aliases(5) for more information about the format of this file.

/etc/mail/virtusertable

This database file maps mail addresses for virtual domains and users to real mailboxes. These mailboxes can be local, remote, aliases defined in /etc/mail/aliases, or files. This allows multiple virtual domains to be hosted on one machine.

The following example demonstrates how to create custom entries using that format:

[email protected]                root
[email protected]          [email protected]
@example.com                    joe

This file is processed in a first match order. When an email address matches the address on the left, it is mapped to the local mailbox listed on the right. The format of the first entry in this example maps a specific email address to a local mailbox, whereas the format of the second entry maps a specific email address to a remote mailbox. Finally, any email address from example.com which has not matched any of the previous entries will match the last mapping and be sent to the local mailbox joe.

Now a little more detailed answers to your questions:

  • The aliases database file contains a list of virtual mailboxes that are expanded to users, files, programs, or other aliases.
  • This virtuser database file maps mail addresses for virtual domains and users to real mailboxes. These mailboxes can be local, remote, aliases defined in /etc/mail/aliases, or files. This allows multiple virtual domains to be hosted on one machine.
  • The sendmail virtusertable feature on the other hand configure support for the virtual user table. The virtual user table maps incoming mail destined for someuser@host to someotheruser@otherhost. One can think of this as an advanced mail alias feature, one that operates using not just the destination user, but also the destination domain. The key portion (on the left) must be either a full address (user, host, and domain name), or an address without a host part (just a domain).

The main difference that I recall is that virtusertable may contain domain information as well as user information; that is; [email protected] and [email protected] are both valid and distinct left-hand-sides in virtusertable, but used together in aliases they will produce a duplicate alias name error.

That still leaves a whole group of entries that can legitimately go in either; my feeling is that one should use aliases wherever possible, leaving virtusertable for those things that are domain-specific.

bangal (q.v.) notes some more important differences, eg the ability to send email to pipes and files.