Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Sending Email from the Command Line

May 11, 2023 — Gregg Szumowski

mutt Examples

Sending just a file attachment (-a) and an empty message body:

$ mutt -s "System logs" -a /opt/backup.sql -- [email protected] < /dev/null

Sending a message body using redirection:

$ mutt -s "Email subject" [email protected] < email.html

Sending a file attachment along with a message body:

$ echo $message | mutt -s "Subject" -a attachment.txt -- [email protected]

mailx Example:


$ echo "message body" | mail -s "subject" [email protected]

Tags: mail, mutt, motd