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: email@example.com
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 firstname.lastname@example.org
# mutt -s "Test mail" -a study.dat email@example.com < 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" firstname.lastname@example.org
Without Message body:
# mutt -s "Test mail" -a study.txt email@example.com < /dev/null