I need to set up a lot of email addresses on a Linux machine, but I don't want to create a new user account for each one.

The mail can stored in a regular maildir or mbox. (I'll be checking the mail through some Perl code running on a cronjob.)

How do I do this?

  • 1
    what mail delevery agent and mail transfer agent are you using? – echox Oct 1 '10 at 17:45

You can use virtual users (and domains) stored on a database so you don't need to create linux users to the mailboxes and the admin of the mail users and domain is very simple, just adding or removing a record in the database table.

an example for ubuntu, postfix and mysql


The full answer really depends on what mail server program you are using.

For both the postfix and sendmail you can redirect mail addresses to local accounts using the /etc/aliases file: any line of the form address: unix-account will deliver email addressed to address@your.domain to the mailbox of unix-account. For example, if /etc/aliases contains a line like this:

postmaster: root

then UNIX user root will get all the mail addressed to postmaster@your.domain, without any need for postmaster to exist as a regular UNIX account.

Instead of a UNIX account name, you can specify the full path of a file -- mail will be delivered to that file (in mbox format). Other redirections are also possible; see man aliases for details.

Note: after editing /etc/aliases, you have to run the command newaliases (as root, typically) in order to have the mail server pick up the new addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy