Markdown, mail, and MarkdownMail

Since I’ve been on a bit of a Markdown kick in my recent posts, I might as well continue with a post about Markdown and email.

Let’s start with MarkdownMail, which I talked about back in September. A couple of weeks ago, Second Gear released Version 2, with (from the release notes)

I’m sure the native iPad support is the biggest new feature for most people, but since I don’t have an iPad, it’s the multiple drafts that I find the most useful. In MarkdownMail 1, you were allowed only one document; to write a new message, you had to delete the old one. Now you can have several messages stored in the app and switch between them at will. This is a huge improvement.

Messages sent from MarkdownMail look pretty good on all the clients I’ve tested. Here’s a message viewed on the iPhone:

Because the iPhone is narrow, I had to stitch three screenshots together to show the whole message. Here’s the same message viewed in Mail.app on my Mac:

And finally, here’s the message viewed in GMail:

As you can see, the rendering in Mail.app and GMail are, for all practical purposes, identical. Generally speaking, I like the way messages from MarkdownMail look, but there are two things that bother me:

  1. Level 1 headers (<h1>) are too big. I do sometimes use headers in mail messages, but I can’t remember ever using more than one level of header. If you do that in MarkdownMail, the huge jump in font size from the <h1> to the body text will be jarring. To get around this, you have to use <h2> or <h3> as your top-level headers, which is very 1995. Stylesheets would solve this problem, but MarkdownMail doesn’t have them.
  2. I really don’t like the iPhone’s rendering of a blockquote as if it were a quoted email. This is not MarkdownMail’s fault—it’s iPhone’s default way of rendering a blockquote—but it’s going to look wrong when the thing you’re quoting isn’t an email.

One very good thing I can say about MarkdownMail 2 is that it’s been rock-solid. In two weeks of use, I’ve never seen it crash or fail to do what it says it’s going to do. Apart from the Posterous blogging thing, I’ve tried all its features and it’s never balked.


I tend to write plain text emails, but sometimes a formatted message does the job better, especially when the message needs tables or complex lists. Like most Markdown users, I’m loathe to write in anything but Markdown, and when I’m working at my desktop or laptop computer, there’s no MarkdownMail available. What to do?

In the past, I’ve done this elaborate multistep operation:

  1. Write the message in Markdown.
  2. Convert it to HTML.
  3. Add a stylesheet to the header.
  4. Open the HTML file in a browser.
  5. Copy the content from the browser and paste into the mail client.

The stylesheet was the key feature. I had one—a stripped-down version of the one used on this blog—made especially for mail that I used again and again, but adding the <script> tag that referenced it was always a pain.

It was after I’d rewritten my blog preview system that I realized I could do the same thing for formatted emails that I’d done for blog entries: set up a simple system that created and opened a nicely styled HTML file with a single keystroke combination. This repository has the two files, a PHP script and a CSS stylesheet, that do the work of collapsing Steps 2-4 above—the most time-consuming steps—into a single action. To run the script, I have a TextMate command called Mail Preview that’s triggered by ⌃⌥⌘M:

The command is two lines of shell script:

php ~/mail-preview/mail-preview.php > ~/mail-preview/mail-preview.html
open ~/mail-preview/mail-preview.html

I’m sure this could be adapted to BBEdit or any other Mac text editor. In fact, something very like these two lines could be used on any operating system.

If you’re wondering why I don’t just use the Rich Text editors built in to Mail.app and GMail, you must not be a Markdown user. The characteristic common to every heavy Markdown user I know is that we want to write everything in Markdown. Now I have MM2 when I’m on my iPhone and Mail Preview when I’m working at my desktop or laptop computer. I may start sending out more formatted mail.