Mail clients nowadays offer you the option of saving a copy of outgoing messages in a Sent folder, and in fact most modern mail clients do this by default (that sure wasn’t the case when I first started using email, 23 years ago!). Unfortunately, it doesn’t always work so well. Here’s another option to for mail hackers to consider.
Saving copies of outgoing messages is usually done in one of three ways:
- If you use a Web mail system, such as Yahoo! Mail, Hotmail, Gmail, etc. it all happens under the covers on the Web server through which you send your messages. If so, then the problem I solve in this blog entry probably doesn’t apply to you, so you can stop reading now.
- Some email clients allow you to automatically add a BCC to every outgoing email message. You can BCC outgoing messages to yourself, and then either use message filters (e.g., in Thunderbird) or procmail or sieve or whatever to file them automatically into your Sent folder, or file them by hand into whatever folder you want them in.
- Some email clients allow you to specify a folder into which copies of outgoing messages should be deposited. After each message is sent to its recipients via SMTP, it’s sent again, but this time via IMAP into the specified folder.
BCC would be the best general-purpose overall solution if it weren’t for the fact that not all mail clients support it. Most notably, Microsoft Outlook does not, although you can add this functionality if you’re willing to hack VBA or pay for a third-party add-on.
Depositing into your Sent folder is something that pretty much all mail clients nowadays support, but it has four significant problems:
- If the message is successfully delivered to its recipients, but then your mail client has trouble for whatever reason saving a copy into your Sent folder, you could end up being left without a copy of the message even though it was in fact delivered.
- The copy that gets saved in your Sent folder is, alas, not always identical to what was sent to the message recipients (Outlook has this problem, and perhaps other mail clients do as well).
- Because you’re sending the message and then saving it, it has to be sent over the network twice (assuming that your Sent folder is on the network). This can be a big deal if the message is large or your Internet pipe is small.
- If you use multiple email clients, then you may find yourself with two or three different Sent folders, because some clients (e.g., the one that comes with Mac OS X and the Blackberry Internet Service) don’t allow you to specify the name of the folder.
In short, neither of these solutions is ideal.
However, if you run your own mail server, then there is another option: archive outgoing messages when they pass through your SMTP server.
The technology that I chose to do this is the ArchiveSMTP milter from Dancing Fortune Software. After patching some issues with ArchiveSMTP, adding an /etc/init.d/archivesmtp script for it, and modifying my sendmail configuration to integrate the new milter into it (“INPUT_MAIL_FILTER(`archivesmtp', `S=unix:/var/run/archivesmtp/archivesmtp.sock')dnl“), here’s the /etc/archivesmtp.conf I’m using to save all of my outgoing email:
{ Sender Is "jik" } Pipe "formail -I 'From ' | /usr/lib/cyrus-imapd/deliver -a jik -m 'user.jik.Sent\\ Items' -q";
This relies on several things: (a) my IMAP and SMTP servers are running on the same host; (b) I use Cyrus IMAPd; and (c) I authenticate to my SMTP server as “jik” before transmitting messages through it. You will probably need to make changes to suit your environment.
Alas, even this is not a universal solution, because it assumes that all of your outgoing email goes through your SMTP server. For Blackberry Internet Service, at least, that isn’t the case. Messages I send through BIS are delivered by Blackberry’s own SMTP servers, not mine. Fortunately, BIS messages at least have a consistent Message ID, unlike Microsoft Outlook, so I can live with having BIS save its own outgoing message copies.