How to Send an Attachment From the Shell
Had to figure this out today and found lots of conflicting and out-of-date
information. The simplest way is to install and use mutt
and works on any
Unix system.
echo | mutt recipient@domain.com -e 'set from=sender@domain.com' -e 'unset realname' -s 'Subject' -a /path/to/attachment.ext
This sends a clean email with a configurable sender email address. The command
sequence is important with the attachment parameter being the last. Otherwise
mutt will blindly try to attach anything following -a
.