Many sites want you to register a “free” userid just to do the most mundane thing (such as downloading a file, viewing a picture, etc). While I don’t have a problem with that requirement in general, I am often quite sceptical about what they plan to do with my userid.
There is a common technique that many people use where they create a site-specific version of their email address (I believed it is often called plussed email addressing). For example, let’s say that my actual address is craig@mydomain.com
and I wanted to signup to flickr, I could
create an email address called craig-flickr@mydomain.com
and use that (and tell my mail server to forward all email to that address to my real craig@mydomain.com
address). The nice thing about this is that if flickr is naughty (not that I am suggesting they are) and sells/gives my email address to spammers, I can immediately determine that by looking at who the email was addressed to.
The problem with this approach is that I have to go into my mail server ahead of time and manually create each site-specific email address. That is a bit of a hassle, and I am sure that I can get away with a simpler approach.
So, given that I am using a combination of qmail and vpopmail to manage my mail server, how might I configure them to do what I want?
Looking at the qmail documentation, I see that the suggested mechanism is to manipulate a file called /home/craig/.qmail-xxx
, where xxx
is the site-specific alias I want. For example, .qmail-flickr
would match any email coming to craig-flickr@mydomain.com
. However, this still means that I have to manually create explicit files for every site I want to sign up to. There is another special variant of this file called .qmail-default
, which is the catch-all for all addresses that don’t have a specific .qmail-xxx
that matches the incoming mail. It looks like this is the guy I want because it should mean I don’t have to keep creating explicit files.
However, as I am using vpopmail to manage multiple domains, the default .qmail-default
file location will not work because qmail doesn’t deliver the mail directly to my /home/craig
mailbox. Instead, it hands all mail to vpopmail who then decides which virtual domain and virtual user to deliver it to.
So, looking at the vpopmail configuration files, I found one called /home/vpopmail/domains/mydomain.com/.qmail-default
. This is the catch-all configuration file for all mail delivered to the mydomain.com
virtual domain.
vpopmail supports a subtle variation on this file that incorporates the user’s email address. I created a file called: /home/vpopmail/domains/mydomain.com/.qmail-craig-default
and added the following:
| /home/vpopmail/bin/vdelivermail '' craig@mydomain.com
Note that the above line contains two single quotes ('
), not a double-quote ("
)
What this does is forward all mail that is addressed to craig-anything@mydomain.com
to craig@mydomain.com
. A quick restart of qmail (/var/qmail/bin/qmailctl restart
) and I was set to go. So, now I can dynamically make up as many combinations of craig-xxx@mydomain.com
as I like without having to create individual .qmail-xxx
files ahead of time.
One thing that you need to be conscious of, though, is that now if spammers send mail to craig-aaa@mydomain.com
, craig-bbb@mydomain.com
, craig-ccc@mydomain.com
, then all that will come through to my inbox, whereas it used to just get thrown away. I think I can live with that, though.
Note This is a re-post of an old blog entry I made years ago on wordpress. I just wanted to keep it up-to-date on my current blog.