A standard Linux email setup gives each user a single address. For
instance, the user jpeek on
the host foo.xyz would have
the address email@example.com.
All email sent to that address would go to a mail spool file like
If a user wants multiple mailboxes, the least efficient way to
do that is probably by giving the user multiple user accounts on the
Linux host: each with its own login and shell setup files, home
directories, and so on.
As the article
are simpler ways for a user to have multiple identities.
One way to have multiple identities is to add multiple system-wide
email aliases, all pointing to the same user's mailbox. For instance,
as shown in this article's page of procmail/formail examples,
the user firstname.lastname@example.org
could gain two new addresses, email@example.com
and firstname.lastname@example.org, if
the system's mail administrator adds two aliases named minutes
and minutes-update to the aliases list
for the foo.xyz MTA. That
setup can be inconvenient, though: each time a user wants a new
address, the system postmaster has to make a new alias.
Another setup lets users choose their own mailbox names -- as many
as they want, and at any time -- by adding a suffix to their email
address. Some systems have implemented this with a plus sign (+) followed by the extended
name. For instance, jpeek
could create new addresses email@example.com
Each user who decides to do this adds recipes to their ,procmailrc file to catch the
messages and do whatever they want with each one.
Pluses and minuses
Using a plus sign (+)
as part of an address can be a problem, though, because some CGI
scripts -- which encode email addresses into URLs -- treat the + as an encoded space character.
So using a dash (minus sign, -)
may be better.
Don't use any arbitrary character, though, without checking mail
standards carefully. Many other non-alphabetic characters are reserved
or can cause problems.
One other possible problem: some email users may confuse a dash
(-) with an underscore (_). So this tip may be best for
addresses that the account owner uses for his own purposes -- or for
correspondents who know the difference between a dash and an
Procmail RC file setup
Here's a user .procmailrc
file that implements the plus-sign separator. The user jpeek assigns the extended part of
the address -- the part after the + -- to a variable named
PLUS. Next is a recipe to handle
mail for the address jpeek+bounced,
which gives him a special address for receiving bounces from his other
procmail recipes (as explained in
# Put address extension into PLUS variable.
# Example: firstname.lastname@example.org sets PLUS to "abc".
# Mail to email@example.com bounced from my procmail setup.
# Toss it into a file. The "w" flag waits for the filter to
# finish and, if it fails, doesn't consider the mail delivered:
* PLUS ?? ^bounces$
| /usr/bin/gzip --fast >>$MAILDIR/bounced-mail.gz
Tip: add a cron job to watch your bounced-mail file
and notify you -- for instance, by email to your main address -- if something
appears in the file.
The following crontab entry uses the test(1) utility to
test for a non-empty bounced-mail file twice an hour.
If the file isn't empty, test -s returns a zero (true) exit
status to the shell;
the shell's && operator emails an ls -l
listing of the file to jpeek.
Be sure to enter this on a single crontab line:
4,34 * * * * f=mail/bounced-mail.gz; test -s $f && ls -l $f | /bin/mail -s "Mail in foohost $f file" jpeek
Here's a description of a setup that allows the Postfix MTA -- along
with procmail as its local
delivery agent -- to implement this system. Thanks to Kimmo Suominen of Global Wire
for this writeup:
The config in Postfix is simple -- just add two lines to
main.cf (which usually lives in /etc/postfix):
recipient_delimiter = +
mailbox_command = /usr/pkg/bin/procmail -Y -p -a "$EXTENSION" -d "$USER"
The EXTENSION and USER variables are setup by the
Postfix system. I'm using -Y
because Postfix does not use the Content-Length:
header field (and neither does sendmail).
I'm using -p to pass all
the useful environment variables from Postfix to the user (as
shown in the .procmailrc
example in the previous section) -- though you can just test on
EXTENSION directly when running with
Postfix. I'm adding the -a
option for backwards compatibility with the old sendmail config I was running before.
The -d "$USER" is
redundant as well with Postfix, since mailbox_command
always runs as the user. But it doesn't hurt and it looks more clear to
[To return to the place where you left the article, use your
browser's "back" button. You can also go to
of the article.]