Monday, August 1, 2011
Sending mail using 'mutt' from shell
In my opinion, 'mutt' is the best text-based Email client for sending mails with Attachment from Linux shell. The best part with it is, it supports wide variety of MIME ("Multipurpose Internet Mail Extensions") types, which ensures the integrity of various types of attachments such as Binary, jpeg, mp3 files.
Below shown are few command sets for sending mails using Mutt with following specifications.
To address: firstname.lastname@example.org
Subject: Test mail
Attachment filename: song.mp3
Message body: "This mail has a mp3 attachment"
# echo "This mail has a mp3 attachment" | mutt -s "Test mail" -a song.mp3 email@example.com
# mutt -s "Test mail" -a study.dat firstname.lastname@example.org < messagefile
Note: "messagefile" is the filename that contains the message body "This mail has a mp3 attachment"
# echo "Mail without attachment" | mutt -s "Test mail" email@example.com
Without Message body:
# mutt -s "Test mail" -a study.txt firstname.lastname@example.org < /dev/null