All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Colour me Spammy

16 June 2004

No matter how much they protest to the contrary, marketeers love sending promotional emails to their customer base. They’ll tell you it’s solicited and more than welcomed by their customers until they’re blue in the face, and just as you’re egging them on to go past blue to, well, dead, they stop to complain about another spam that has just arrived in their inbox.

As a web developer, it often falls to you to develop the applications to power their spammy evilness. At the moment I’m averaging one such system every two years or so – that’s not too bad considering marketeers are stuck with being marketeers for life. When designing such a system it quickly becomes apparent that a web app isn’t the most efficient place to be sending mail from. In terms of logistics it’s a good place to be composing the mail (you have a database of content sat right there on the site) and to assemble the ‘hit’ lists (similarly, a complete list of web site users), and so whilst you’re doing all the hard work on the site you might as well send from there too, right? That tends to be the way the decision goes, simply because investing in a second system for deploying the mailing is uneconomical.

Each time you write a bulk mailer – or spam machine as I lovingly refer to them – you get a little better at the implementation. The weakness, however, is always the process of sending the emails themselves. It nearly always comes down to some sort of loop that goes through each record in the hit list and sends a single mail. It’s time consuming and as dull as buggery. Desperate to find a solution to this, I started looking at various mailing list management tools, trying to find something I could dynamically subscribe addresses to. My thinking was that if I could assemble the hit list, I could then subscribe each address to a proper list server and have that send the mail for me. After much poking around on my web server, none of the list managers I had seemed to be able to help. It all came down to sending a ‘subscribe’ email, which rather defeated the point.

I came across the solution I was looking for through a totally unrelated conversation with the emailmeister himself, Steve Champeon. He had made mention of a mailing list that was simply based on a sendmail alias – and after a quick bit of googling I had my solution. Here’s the skinny.

Unix based systems have an inbuilt ability to alias one email address to another. It’s just something they do, and it’s usually found somewhere like /etc/aliases or /etc/mail/aliases. The format of the file is simple:

aliased-user: real-user

The handy bit for me is the fact that you can include the address of a file containing a one-per-line list of addresses for an alias to map to. The syntax goes like this:

aliased-user: :include:/home/whatever/mylist.txt

All I then needed to do was to populate mylist.txt with the addresses I wanted to send to, and then fire off an email BCC’d to aliased-user@domain.com, and the mail server does the rest. Of course, you don’t want to send directly to the list alias, as that would reveal the address to everyone on the list. To be doubly sure, I also clear out the contents of the list file once I’m done.

So, not only am I a spammer, but I’m a crafty one at that.

- Drew McLellan

Comments

  1. § Jesse: Evil.

    The ‘just following orders’ excuse doesn’t work :p
  2. § Jeff Adams: Anytime I get approched to do this sort of work I turn it down. No amount of money is worth supporting the horror that is spam.
  3. § Drew McLellan: Jeff- that would be one of the benefits of being ones own boss, I guess.

    My post was rather tongue-in-cheek. I’m generally referring to newsletters and such that get sent out from a membership-based web site to its opted-in subscriber base.
  4. § Jennifer Grucza: Right – not all bulk email is bad. I rather like getting emails about special sales at jcrew, or emails with coupons to Borders, for instance. :)
  5. § me: I can’t imagine what’s so hard about doing what the other program is doing. I guess you are running your app from a web page and you are concerned about a timeout … well you could fork it (and tell sendmail or whatever to send it when it can). Also there are libraries which will take all your addresses and bulk send to each domain rather than send an email to each user at each domain. Personally none of these solutions have ever worked for me as I’ve always wanted to personalize the email for the user, not just one email fits all.

    As a developer I always felt it my responsibility to educate others around me. I worked at an ad agency. I argued and won to set the default choice TO NOT BE included in an email list and to make it EASY for people to unsubscribe. I’d seriously consider walking from a job that sent unsolicited email to people.

    Orders are no excuse.
  6. § Drew McLellan: ‘me’ – both the things you mention (opt in and easy unsubscribe) are legal requirements here in the UK, so no sweat on that front. I agree with your sentiments. Education is critical, and believe me a lot of it goes on around here.

    It’s a shame you felt you couldn’t stand by your comments and add your name, however.
  7. § Jesse: Wow. You win one fight on a way software works me.. so either you work in education where you can actually ‘argue’ without losing your job, or you are someone who changes jobs often.

    I am surprised anyone wants to create anything that isn’t ‘opt-in’ giving the potential legal implications.. but meh.
  8. § Jan!: The problem with this approach is that the mail isn’t sent to each subscriber separately. That means they don’t see their address in the To: field, so it’s a bit less personal and more likely to end up in their bulk mail folder.

    Of course, for a lot of purposes, this approach will do just fine, so it all depends on the demands of the job.
  9. § Paul: The way I have done it twice in the past, is to write the email template to be sent to a database table with a status of ‘queued’ then have a cron job that checks for any queued messages and sends them out. It’s not ‘real-time’ but then if you have the cron job running every half hour like I do, then it is real-time enough :-)

    It also allows you to send one mail at a time and personalise them without having to put up with the time-out possibilities of a web front end.

    Works for me!

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

About Drew McLellan

Photo of Drew McLellan

Drew McLellan has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.