If you need to send an email with a text file (or binary file) as attachment using shell script or command prompt in Unix or Linux; try mutt - a terminal-based e-mail client for Unix-like systems.
mutt -s "Test mail" -a /tmp/shahzeb.tar.gz email@example.com < /tmp/mailmessage.txt
- firstname.lastname@example.org - is the recipient.
- /tmp/mailmessage.txt - is the main body of the e-mail (read message from the file "mailmessage.txt").
- -a /tmp/shahzeb.tar.gz - is an attachment.
- -s "Test mail" - is a subject line of email Message.
If MUTT is not available???If mutt is not installed, use the apt-get or yum or up2date commands as follows (you must login as a root user). Debian / Ubuntu Linux user type the following command to install mutt client:
# apt-get install muttOR
# yum install mutt