Simple Email Forwarding with Virtualmin

Setting up email addresses for a custom domain (ie: yourname@yourdomain.com ) is probably the easiest thing you can do to add professionalism to your business, brand, or project. Frankly, if your business email address is YourBusinessName123@hotmail.com I can’t take you seriously.

There are many ways to do this – most domain registrars offer this as an added, paid service (and generally grossly overcharge). However, this option comes with a few downsides:

Usually, they offer you a mailbox with a tiny amount of storage and a terrible interface, making your only reasonable option fetching the mail into a different client (gmail, thunderbird, outlook, etc) via POP3 or IMAP. This means you aren’t getting your mail in real time. Additionally, if you are using a client on your computer or phone to fetch the email directly (instead of a different provider, like gmail), you either have to leave it on their server (and run up on those ridiculously low mailbox limits) or risk only having the email on one of your many devices. Not a good solution.

Moreover, if you have LOTS of domain names, paying $7 a month for each one can add up VERY QUICKLY. I’m currently running email addresses for over 20 domains – there is no way I will pay ~$150/month just to get my email addresses.

Take heart, there is a better way! Setting up your own email server is a snap, assuming you already have a server box running somewhere (if not, maybe it is time to go get one!). I use virtualmin to manage all my servers, so getting procmail and postfix set up is literally done for me. If you are hosting your own site, this process should be just one of the steps in setting that up. However, if you already have a site hosted elsewhere, you can still use virtualmin for your email addresses.

Before you start, you need to decide if you want a mailbox on the server (holds all your mail, you can fetch it using POP3/IMAP or read it on server using various mail tools) or if you just want to forward incoming mail to another address (or both!). For my small projects, I generally forward the email on to my regular gmail account instead of storing the mail on the server. This lets me get my email in real time AND take advantage of gmail’s excellent spam filtering. NOTE: if you do this, you MUST tell procmail to NOT modify the message container at all (or add SPAM to the subject line), or gmail will decide YOU are the one sending all that spam and block everything coming from your server. YOU DO NOT WANT THIS. Read this for more details.

The first action you need to take is adding a virtual server for your new domain. Add your domain name and hit create. When virtualmin is finished setting up your server, click ‘Return to Virtual Server Details’.

Virtualmin - Create New Virtual Server

Virtualmin - Virtual Server Created

Scroll down a bit then click the button for ‘Edit Mail Aliases’ (click ‘Edit Users’ if you want to set up a mailbox on the server instead of just forwarding). On the following page, click the link for ‘Add an alias to this domain’.

Virtualmin - Add Mail Alias

Now, add whatever you want the email address to be to the ‘Name’ field (the yourname part of yourname@yourdomain.com). If you already are using a mailbox on the server you can check the ‘Deliver Locally?’ box and add the mailbox name. Check the ‘Forward to other address’ box and enter the email address where you want this mail to go. There are lots of other options you can use here, like setting up automatic replies or bouncing the mail. Hit ‘Create’ when you’re finished and the server will be set up!

Virtualmin - Creating Mail Alias

Now, if you email that address, NOTHING WILL HAPPEN. What? This is because the internet doesn’t magically know that your server is ready to process mail for your domain. To finish this setup, you need to go to your domain registrar and point your MX records at your server. Get your server IP (mine are on Amazon, so I grab the public IP from the AWS console) and put it in a new A record (mine is named mail), then add an MX record pointing to that (mail.yourdomain.com). This will send emails on to your email server without changing your website hosting.

DNS Settings - A and MX Records

Wait for the changes to propagate across the internet, then send yourself a test email. See, wasn’t that easy?

EasyMarkdown.com – A New Microproject

I had the itch recently to take on a new microproject, inspired partially by the need to convert a bunch of text in word documents to clean html. Markdown immediately came to mind, so a tiny web editor with instant html conversion sounded like a great idea. And just like that, EasyMarkdown.com was born!

mockup_final

In an effort to get the most out of these little ‘whim’ projects, I’ve started writing up walkthroughs of the entire process, from first idea all the way through deployment. EasyMarkdown.com is no exception, and in fact is probably the best one so far, with a fancy development timelapse and everything. I haven’t yet nailed down exactly how I’m going to be presenting these (and none of them are polished enough for public consumption), so for now you can just have a look at the site in ‘Minimal Viable App’ form.

Fun times.

If you are interested in reading the walkthrough, I’d love to know (at this point I don’t even know if anyone will care). If you have any suggestions for how to present the walkthroughs in general, I want to know that too. Email me or leave a comment below.

Preventing Backspace from Navigating Backwards – Mootools Edition

In my experience, most people don’t know that backspace is a cross browser standard used for going ‘back’ a page – literally a shortcut for hitting the back arrow.

Personally, I hate this functionality because it overloads what the backspace key does with two WILDLY different behaviors and the only difference is what is currently highlighted. Eventually you will try to click on an input and hit backspace to erase what is there, but you missed the input or grazed tab or something else happened that took the focus from that element and backspace sent you back a page. In my opinion, this is really bad UI.

However, my view on this is clearly not universal. In fact, there is actually a fairly large and heated argument online between the haters and the proponents of backspace = back navigation. That being said, the request for developers to make that stop happening is fairly common.

I ran into this request recently myself and was happy to oblige. A quick search led to a stack overflow question where this was, in my opinion, the cleanest and most thorough answer. However, my project uses mootools and this snippet is in jquery. I converted it over and am posting it here, both for when I inevitably need it in the future and for anyone else out there who stumbles across it.

The usual disclosures apply – I haven’t tested this thoroughly across all browsers or operating systems or anything else. I AM using it in a production environment, but before you do so you need to fully go through the code and test everything on your end. Your mileage my vary, and it is entirely your responsibility.

// Mootools Version
//Prevents backspace except in the case of textareas and text inputs to prevent user navigation.
$(document).addEvent('keydown', function(e){
 
    var preventKeyPress;
    if (e.key == 'backspace') {
 
        var d = e.target;
        switch (d.tagName.toUpperCase()) {
            case 'TEXTAREA':
                preventKeyPress = d.readOnly || d.disabled;
                break;
            case 'INPUT':
                preventKeyPress = d.readOnly || d.disabled ||
                    (d.attributes["type"] && $.inArray(d.attributes["type"].value.toLowerCase(), ["radio", "checkbox", "submit", "button"]) >= 0);
                break;
            case 'DIV':
                preventKeyPress = d.readOnly || d.disabled || !(d.attributes["contentEditable"] && d.attributes["contentEditable"].value == "true");
                break;
            default:
                preventKeyPress = true;
                break;
        }
    }
    else
        preventKeyPress = false;
 
    if (preventKeyPress)
        e.stop();
});

Windows 8

Last month I bought a new laptop in preparation for two very long plane rides and a looming deadline. My intent was to immediately wipe the machine and install linux on it, but since I had not tried Windows 8 yet I figured I would try to give it a fair shot. I expected the worst – Microsoft has consistently let me down for a very long time – but I was generally not disgusted! I immediately installed a start menu (seriously, crippled dashboard only?) but with that addition everything seemed to go ok. I had some serious trouble compiling some libraries I needed, but that was pretty much the case across ALL windows versions, not just 8.

You could sum up my feelings as “Meh, not as bad as I was expecting”, which is actually a glowing endorsement from me as far as microsoft products go.

I had my development stuff already set up and win 8 wasn’t really getting in my way after that so I never ended up wiping the machine. Until today.

Rewind 2 days. Windows installed some updates which the engineers STILL couldn’t be bothered to write without requiring a restart. I decided to be proactive and restarted immediately. The ‘your machine is going to restart in 2 days to apply updates’ warning didn’t go away — apparently restarting isn’t always the same as restarting, if you know what I mean (what?). Strike one.

Zoom back to today. I was diligently working away and the laptop overlaid my entire screen with a warning telling me it was going to restart for updates in 15 minutes. Annoying as hell, but whatever. I was nearly finished with a fairly in depth review task and I foolishly assumed I could delay this a couple times until I was done for the night. 15 minutes later, in the middle of a sentence, the laptop restarts. Strike two through 1 million.

This is a call for retirement. There are two people who I would like to request step down from their positions and leave the software industry altogether — the person who proposed the idea that my computer should shut itself down out from under me and the highest manager up the line who approved it and let it ship. You don’t have the first clue about people, their computers, or what the former would like from the latter. You should move into a less mentally taxing job more suited to your talents — my suggestion/hope is you take up drunkenly blaming the local pidgeon population for stealing your teeth while publicly urinating on a park bench.

Also, a note to everyone at microsoft — the computer using population is gaining competence, wealth, and options. It is time to stop hiding behind the money you made when people didn’t have any other choices and join the world where people can actually use a computer that doesn’t make them want to hurt someone.

tl;dr – I’m back to hating microsoft in full force.

Uniform.js doesn’t update when changing select inputs

I ran into a bug today where I was programatically updating a select box’s options and specifying the selected value but uniform.js wasn’t displaying the changes. Here is a fiddle showing the problem. Two identical selects are emptied then repopulated. The uniform styled one still shows the original value of ‘two’ while the browser select correctly shows the first new option ‘—-’.

Luckily, if you update Uniform to 2.x you can fix the display by simply re-calling .uniform on the given select, as seen below (jsfiddle.net link).