I want a utility that does something like this:
email --subject="message" --body=body.txt --email@example.com
(using pre-configured sender information for e.g. gmail). Note that
body.txtis plain text and should be the body of the message, not an attachment. If the body is omitted it should pop up an editor and let me type in my message that way.
I could hack together a quick script that does this, but I was wondering if there’s an easy way to do this with common unix tools?
The mail/mailx utilities do most of what you want. What it does not do, is open an editor on empty contents. The body of the email is read through
stdin. Here is an example on usage:
mail -s "message" firstname.lastname@example.org < body.txt