Lino Website

surf notes

Using Thunderbird to edit and send generated e-mails

Thursday, 11. May 2006 13:20.

I would like to have Lino or TIM generate complex e-mails into a text file and then invoke the user's e-mail client to load this file into its editor where the user can edit it and finally click the «Send» button.

The articles kb.mozillazine.org/Thunderbird_Command_Line_Arguments, kb.mozillazine.org/Command_line_arguments and www.mozilla.org/docs/command-line-args.html describe Thunderbird's command-line syntax, but this approach is not usable if the message body has a certain length and/or complexity.

What they don't mention is that with a recent version of Thunderbird it is now possible to invoke Thunderbird from a command line with a file's name as argument. This file must then be in RFC850 format.

So I can generate a file tmp.eml with the following content:

Date: Wed, 03 May 2006 11:23:17 +0200
From: me@example.com
To: you@example.com
Subject: Ping
Content-Type: text/plain; charset=ISO-8859-1

blabla bla

However with the above example, Thunderbird displays the message, but the user cannot hit Ctrl-E ("Edit as new") in order to edit and send it. I discovered that the Message-ID header field is required if I want this to be possible.

Date: Wed, 03 May 2006 11:23:17 +0200
From: me@example.com
To: you@example.com
Subject: Ping
Message-ID: <1234@example.com>
Content-Type: text/plain; charset=ISO-8859-1

blabla bla

I observed that if my generated file contains an error, for example if I specify an invalid date in my tmp.eml file...

Date: invalid date!
From: me@example.com
To: you@example.com
Subject: Ping
Message-ID: <1234@example.com>
Content-Type: text/plain; charset=ISO-8859-1

blabla bla

... then Thunderbird just doesn't display the message, without letting me know about the error.

Another Thunderbird bug is that if I invoke Thunderbird with a first message, then generate another message with the same filename and invoke Thunderbird again, then Thunderbird seems to have cached my previous file and does not read the new version of it.

And another strange behaviour: the file's name must end with ".eml", not with ".EML"!

Copyright 2001-2007 Luc Saffre.
http://lino.saffre-rumma.ee
Generated 2007-06-07 16:22:43