Quick Tip: Thunderbird Email from the Command Line
Basics
Thunderbird messages can be composed from the command line, and the syntax is pretty basic (field=’value’). For Example:
admin@box:$ thunderbird –compose “to=’foo@bar.com,bar@foo.com’,subject=’nice tip’,attachment=’file:///home/admin/tip.txt’,body=’Check out this neat command line tip’”
Caveats:
Values don’t have to be in single quotes. However, if you have multiple values or characters that might be interpreted by Thunderbird, as actually being part of the command, you will get results you may not have intended. So, put the whole part after –compose in double quotes and use single quotes for the values. You also need to make sure that there are no spaces after or before the commas that separate the field value pairs (Basically anything outside of the single quotes). Lastly, this is not entirely from the command line. The Thunderbird compose email window will pop up with the fields populated, so you can edit them and then send it.
Tip:
This can be combined with command substitution. So if you want to email a file to someone with the contents of a file in the body of the message and not as an attachment you can do the following:
admin@box:$ thunderbird –compose “to=’foo@bar.com’,subject=’I sent this message using command substitution’,body=’$(cat file.txt)’”
You can now enjoy having some of the power of the command line in your email while still just using a simple gui application.
Reference:
http://www.mozilla.org/docs/command-line-args.html
pretty handy !!
Ocean
4 Feb 09 at 4:33 am
kewl, now how does one send that email from the command line?
Curt
5 Mar 09 at 4:26 am
Hi Curt,
When I did this I didn’t find a option to the command to go ahead and send the mail. There are really better tools for this anyways, for example, xmail.
But if you really want to do this, you maybe could use this very ugly hack after installing xdotool:
thunderbird –compose “to=’foo@foo.com’,subject=’nice tip’,body=’Check out this neat command line tip’” &; sleep 2; xdotool key ‘ctrl+Return’
This will just send the keyboard shortcut to the currently selected window 2 seconds after running the thunderbird command. Also note, the thunderbird command is put in the background as a job with the ampersand.
-Kyle
admin
6 Mar 09 at 5:54 am