Postpostmodern » Email http://postpostmodern.com Speaking of web development. Wed, 11 Jan 2012 00:21:50 +0000 http://wordpress.org/?v=2.9.1 en hourly 1 Quick Email Aliases on Media Temple http://postpostmodern.com/2006/11/29/quick-email-aliases-on-media-temple/ http://postpostmodern.com/2006/11/29/quick-email-aliases-on-media-temple/#comments Wed, 29 Nov 2006 05:17:41 +0000 Jason Johnson http://blog.postpostmodern.com/2006/11/29/adding-email-aliases-on-a-media-temple-dv-server/ The Short Story:

If you have a Media Temple (dv) vps server account with Ruby1 installed and root/sudo access, you can use my handy-dandy script to create instant email aliases for any of your hosted domains.

Usage2:

sudo ./alias.rb email_alias@hosted-domain.com recipient@anydomain.com

That’s it. 5 seconds and you have a new email alias. No Plesky mess involved.

I even aliased my alias script in my .bashrc file:

alias ealias='sudo ~/alias.rb'

The Backstory (and how the script works):

I use a lot of email aliases. I rarely give out my real email address. I usually create an alias that forwards to my real address. For example, if Amazon.com thinks my email address is amazon (@ my domain.com). That way, if I ever start getting spam, I know who gave away my address, and I can just delete the alias.

I use Media Temple’s Dedicated Virtual (dv) hosting plan. The Plesk control panel is kinda limited (and a pain) when it comes to creating lots of email aliases. I’ve yet to find a way to create an alias that forwards to an external email address, and any alias creation takes a crapload of mouse clicks. So, I decided to figure out a simpler way. After looking under hood, I discovered qmail. I didn’t know a thing about qmail, but I was willing to do some research to get to a solution for my alias thing. It turns out, qmail has kind of a neat way of dealing with aliases: for each domain, there is a directory. Each file in this directory represents an email alias3. The files are named thusly: ‘.qmail-alias’ where alias is the actual name part of the alias address. The contents of the file consist of the actual recipient addresses (prefixed by & and separated by newlines). So, a file called .qmail-amazon in /var/qmail/mailnames/postpostmodern.com that contains my real email address, prefixed by an ampersand, would be all that is needed for a functioning alias. All my script does is parse the input to figure out the name of the file, the contents of the file and where to put the file. Then, of course, it just creates the file.

The nice thing about qmail’s system is that the files are utilized instantly. There is no reloading of alias info or anything. It just works.

Oh, and adding a bash alias like this:

alias emails='sudo ls -a /var/qmail/mailnames/hosteddomain.com/'

will give you a list of existing aliases.

  1. Yes, I could have used Bash or something, but I’m more comfortable with Ruby, okay? ↑ back up there
  2. Please adjust the shebang line for your ruby installation. And don’t forget to chmod the script so it’s executable (755)! ↑ back up there
  3. There are also subdirectories for each real email account. ↑ back up there
]]>
http://postpostmodern.com/2006/11/29/quick-email-aliases-on-media-temple/feed/ 7