Mac Installation Email 101

1:00 am in Technology by Gaz

This is the fourth part of a short series of posts about installing Mac OS X. Today’s article covers my email setup. If you missed earlier parts, links are at the end of this post. After this I’ll cover the last few installation goodies in the upcoming final part of the series.

Having locked down and configured my macBook configuration and then installed my favourite productivity applications as described in the earlier parts of the series, one of the last things I need to do is set up my Email access.

I’ve used a huge number email clients over the years (my first job out of University sat me opposite Malc Arnold, author of the esoteric AF), but despite it’s limitations Apple Mail is so well integrated with the OS that, for all the times I’ve become annoyed with it and flirted with other clients, I’ve always come back to Apple Mail. There are also a tremendous swathe of addons and plugins that can fill in for some of the worst missing features.

Here’s what I do to Apple Mail to have it work just the way I like…

1. Edit in Textmate

textmate.pngApple mail is a nice place to manage all my email, but I certainly don’t want to be stuck with it for editing my emails when I have TextMate installed on my machine already. Among its many talents, TextMate makes a fine email editor capable of refilling quoted paragraphs correctly while still keeping the quote marks nested properly, among others. The feature isn’t well documented but involves installing an input manager from TextMate. In the TextMate menu on the cog button in the middle of the Textmate status bar is an entry called Install "Edit in TextMate"... which guides you through the process.

You might need to set up the syntax colouring for nested quotes in the Fonts & Colors preferences for your colour theme. But that is simply a matter of creating elements for various levels of nested markup.quote scope selectors, and attaching appropriate colours as usual.

Once installed, reply to emails with Mail as usual, but select Edit in TextMate from the Edit menu to transfer the contents of the reply window into TextMate. When you’re done, press Command-S Command-W to save your reply and transfer it back into Mail ready for sending.

Price: €39, but TextMate is much more than a just a swanky email editor.

2. GPGMail

gpgmail.jpgI always digitally sign all of my outgoing mail (unless I’m stranded with only someone else’s machine and webmail), and GPGMail is a bundle that wraps the FSF‘s GPG cryptographic toolkit up for Mail.

It doesn’t come with its own copy of GPG, which is a good thing because it hasn’t been updated in a while, and I like to run with the latest stable GPG from MacPorts. GPGMail looks for a GPG binary at /usr/local/bin/gpg, so after MacPorts has built its GPG in /opt/local/bin/gpg, you have to create a softlink to keep GPGMail happy:

$ sudo ln -s /opt/local/bin/gpg /usr/local/bin/

After I first upgraded to a macBook, I noticed that Apple Mail would often forget to mark messages I’d looked at as read on the IMAP server, so when I next started it up, a few dozen messages from the last few days in each folder would be marked as unread again. Eventually, I narrowed it down to a bug in GPGMail which allowed the local cached copy of messages to be correctly marked read, but often stopped the IMAP server from being updated. To stop this happening be sure to deselect the following options in the Viewing tab of GPGMail’s preferences:

  • Authenticate Messages Automatically
  • Decrypt Messages Automatically

For security, I have GPGMail set to always ask me for my passphrase, and then discard it from memory, so it wasn’t able to automatically authenticate or decrypt without prompting me anyway. Turning off those options doesn’t actually degrade GPGMail, but it does keep the IMAP server properly informed of which messages I have read.

Price: $0

3. LetterBox

letterbox.jpgWith a widescreen macBook, it’s a shame to waste a lot of real estate by stacking the message list and the message view vertically. You can see some screen shots of how Apple Mail looks with the LetterBox plugin installed in this older post. Rather than compromising with either a tiny view of the message list, or having to scroll down on every message in the viewer to get to the reply text, LetterBox allows full height for both panes by putting them next to each other horizontally.

Price: $0

4. Mail Act-On

mailacton.jpgFor keeping track of actions that come at me via email, Mail Act-On is a godsend for me. It hooks into Mail’s existing rules configuration, allowing you to run anything you can do with a Mail rule with a simple key press. And if that isn’t already flexible enough for you, it is written by the author of Mail Tags, so the two work together extremely well.

Price: $0

5. Mail Tags 2

mailtags.jpgI bought a license for Mail Tags to help me implement my Digital Third with Journler. I still need to find time to evaluate iGTD as a replacement for Journler, especially as it has such excellent Mail Tags integration. More on that in another post. In the mean while, I can continue using the Mail Tags based workflow I’ve become used to over the last six months or so.

Price: $29.95 with a 21 day free trial.

6. Next Unread

One of the major gripes I used to have with Apple Mail is the lack of a next unread mail shortcut. I attach the following Applescript to Command-N using a Quicksilver trigger. With Quicksilver set to only fire this trigger in Mail, I can now press Command-N, and focus moves to the next unread message in the current folder:

tell application “Mail”

    - - Get date & subject of first selected message
    set theSelection to selection
    set theDate to date received of item 1 of theSelection
    set theSubject to my trimRe(subject of item 1 of theSelection)

    - - Make a list of unread messages in selected mailboxes newer
            than currently selected message

    set messageList to {}
    get selected mailboxes of message viewer 1
    repeat with thisBox in result
        - - Use “read date < theDate” to find previous unread message
        set messageList to messageList & (messages of thisBox
                whose date received > theDate and read status
                is false)
    end repeat

    set nextMessage to {}
    - - Remove the following block unless you “Organize by Thread”
    repeat with thisMessage in messageList
        if my trimRe(subject of thisMessage) is theSubject then
            set nextMessage to {(thisMessage)}
        end if
    end repeat

    - - If there is a newer unread message, select it.
    try
        if nextMessage‘s length > 0 then
            set message viewer 1′s selected messages to nextMessage
        else
            - - Use “{(messageList’s first item)}” to find previous unread message
            set message viewer 1′s selected messages to {(messageList‘s last item)}
        end if         activate
    on error
        beep
    end try
end tell

- - Trim all ‘Re: ‘ prefixes from theSubject
on trimRe(theSubject)
    set thePrefix to characters 1 thru 4 of theSubject as string

    repeat while thePrefix is “Re: “
        set theSubject to characters 5 thru end of theSubject
                as string
        set thePrefix to characters 1 thru 4 of theSubject as string
    end repeat
    return theSubject end trimRe

Currently the script is optimised for viewing in threaded mode with all threads expanded. If you don’t organize by thread, then you should remove the repeat loop for setting nextMessage before compiling the script. Also, this will find your previous unread mail if you sort your messages with newest at the top, but again, the script is easy to fix. Unfortunately, the Mail Applescript dictionary doesn’t supply any means for the script to interact with message threading, or I could have made the script automatically select the appropriate behaviour.

As it stands, if you seem to lose the message selection after pressing Command-N, it’s probably focused inside a collapsed thread… just remember to Expand All Threads before stepping through unread messages.

Price: A Pint of Guinness if you like it!

7. Postfix Enabler

postfix.jpgAs a frequent traveler, it’s impossible to rely on having an always-on internet connection. If I wasn’t lazy (and laziness is a virtue for an engineer!), I could remember to save drafts of my outgoing emails when I’m not connected, and then send them manually when my connection next comes up. Postfix Enabler is a straight forward GUI to tweak the configuration in Mac OS X’s bundled mail daemon so that it will do all that for me. I simply point Mail.app at localhost, and I can reply to and send emails to my hearts content, safe in the knowledge that my suitably enabled Postfix daemon will queue the messages, and resend automatically when the opportunity arises.

Another benefit of running Postfix as a smart forwarder is that I have some scripts set up to fire notification emails to the appropriate mailing lists when I commit changes to the GNU projects I contribute to. By pointing those scripts at localhost:25, sending those emails is easy even from a shell script.

Price: $9.99

Related Articles

  1. Mac Installation Security 101
  2. Mac Installation Configuration 101
  3. Mac Installation Applications 101