Sending Email from the Command Line with mutt
June 07, 2023 —
Gregg Szumowski
If you prefer using mutt
as your command line email
tool, then here are a couple of examples of using mutt
to
send emails which can be automated quite easily to use in scripts.
Sending a file attachment (-a) and an empty message body:
$ mutt -s "System Logs" -a /var/log/somelog.log -- username@example.com < /dev/null
Sending a message body using redirection:
$ mutt -s "Email Subject" username@example.com < email.html
Sending a file attachment along with a message body:
$ echo $message | mutt -s "Email Subject" -a attachment.txt -- username@example.com