Sending a file as the body of an email

I want a utility that does something like this:

email --subject="message" --body=body.txt

(using pre-configured sender information for e.g. gmail). Note that body.txt is 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" < body.txt

Source : Link , Question Author : Ismail Badawi , Answer Author : jordanm

Leave a Comment