Yesterday, I gave thought to the possibility of creating a simple newsletter. I regularly cross-post links to my articles on Facebook and Twitter—this is handled automatically with Zapier. However, not everyone uses those services and quite frankly I can't be bothered with maintaining a presence on the myriad of social media services out there.
When I sent out an email outlining the plan to friends and family, the responses were encouraging. So, on the way home last night I wondered about how I would go about creating such a project given that my website is created by a static-site generator and does not utilise any servers-side code or databases.
The obvious and most popular choice is MailChimp, a freemium service whose sole purpose is to manage email marketing campaigns. I am reasonably familiar with the service, having used it for the local community group for whom I provide IT support.
I do think MailChimp is a good option, particularly for large campaigns and when you're working in a team with writers and designers who prefer to create content with a WYSIWYG editor. However, I don't need that kind of scale, nor do I need collaboration. I work on my own. I'm also perfectly happy writing my content in markdown; in fact I prefer this to the idea of logging into MailChimp just to write and send email.
There's also a part of me that's not comfortable storing people's data in a third-party cloud service (this has implications for my current comment provider, Disquss, which I'll address in a later post).
The simplest implementation needs only a means to manage a list of contacts and the email infrastructure to send the email. I can do all that using the features baked into almost any operating system. For example, I could store the contacts in my Mac's Contacts app under a Chris Rosser Newsletter group and simply use Mail.app to write and send the email.
That would work. However, if I get a lot of sign-ups (you never know…), it wouldn't scale very well not least because it would pollute my Contact's app with more records than I'd like. I'd also like to be able to automate some tasks, for example sending out notifications of new posts either as I published them or according to a schedule.
The only personal information I need is a reader's email address. Anything else is quite frankly, none of my business. That got me thinking that I don't need a database at all—in fact, all I need is a text file containing the list of addresses.
A simple Python script can handle the logic. It can read and parse my blog's RSS feed, load the email list, convert the newsletter text from markdown to HTML and send the email. Scheduling tasks, such as weekly publications, can be done through a cronjob executed on my home server.
For handling signups I'll use the simplest approach possible. I'll create a form on the site that only requests an email address. The form will post to a PHP page that validates the email address and purges anything else a spambot tries to push through. Once that's done, the script will then pass on the email address to me via email. The email will arrive on my phone, allowing me to eyeball requests and remove any spam that manages to get through. I can then add the email to my list and notify the recipient via email, most likely using a Workflow.
I like this approach and it shouldn't take long to implement.