During the migration to Blogger, I used the post-by-mail service to ease the move of all posts. I downloaded all the old ones into my computer and then automatically sent a mail for each of them to the appropriate posting address.
However, this was not easy. As all the posts were in HTML format, I needed to tell the mailer to send a multipart message with a text/html part. After many attempts, NetBSD's mail(1) command proved to be insufficient so I had to look for another mailing utility to do the same thing. (Note that I know few things about the mail protocol, so I can be missing something.)
My first thought was that Mutt could help. Indeed, if I composed an empty mail and attached an HTML file, it did what I wanted. The problem came when I had to automate this from a script... The first attempt was something like:
mutt -s "$(cat mail/$f.subject)" -a mail/$f.html firstname.lastname@example.org
Ok, this worked, but having to type [Enter][Enter], then :wq and then y for each message was not automatic. The first thing I solved was the save and edit part from the editor. Instead of using vi(1), I asked Mutt to use touch(1):
EDITOR=touch mutt -s "$(cat mail/$f.subject)" -a mail/$f.html email@example.com
This solved the :wq part but I still had to type [Enter][Enter]y for each post. How to solve it... I searched a bit (I mean, Googleed a bit) and found that giving /dev/null as the standard input to Mutt was enough to silence it. So the command ended being as:
EDITOR=touch mutt -s "$(cat mail/$f.subject)" -a mail/$f.html firstname.lastname@example.org </dev/null
Still, it'd be nice if the standard mail(1) utility was able to send complex messages...