Herr Bischoff

How to Send an Email With Attachment From the Command Line

The easiest way is using mutt:

mutt -s "Subject" -a /path/to/file -- name@domain.tld < /dev/null

Multiple attachments are possible as well:

mutt -s "Subject" -a /path/to/file -a /path/to/file -a /path/to/file -- name@domain.tld < /dev/null


Reader Patrick Hemmen reported an alternative approach using mpack, a small MIME encode/decoder.

mpack -s "Subject" /path/to/file name@domain.tld

The software was last updated in 2003 though and may contain unfixed issues. It can also send only one attachment at a time. Still, it’s good to know about different ways of achieving the same goal.