I discovered a stupid bug in Apple Mail today.

I have a SSH tunnel set up on my PowerBook back to a Linux machine at work so I can securely check my IMAP mail from open wireless networks. Today in class I found that the wireless network I’m on blocks outbound port 25, so I set up the SSH tunnel to take port 25 traffic back to my SMTP servers. This is a really cool trick, and you can do this all on a single SSH line:

ssh user@some.server.org -L2143:mail.server.org:143 -L2525:mail.server.org:25

This opens an SSH session to some.server.org, and then forwards your local port 2143 to mail.server.org:143, and likewise for port 25. You can chain as many of these ports as you need into a single SSH session.

So I set up the outbound server in Mail to “localhost:25″. No luck, Mail was having none of it. I could telnet to localhost 25 from commandline just fine. My IMAP connection is localhost:143 and that works in Mail. Puzzled, I tried 127:0.0.1:25 and THAT works.

How on earth did that happen? These preferences are in the same pane in the Mail Preferences. Someone had to specifically code Mail to allow “localhost” for IMAP, but not for SMTP.

Dumb.