Thursday, September 11, 2008

Send email with attachment from terminal

To be able to do as the above mentioned, a tool named mutt is needed. Mutt is a mail user agent (MUA) and a very excellent one in my opinion. To install mutt:

  • # yum install mutt
To send email, you can use this commands (Choose whichever you like):
  • # echo "your messages" | mail -s "your subject" johndoe@yahoo.com
    • where -s is for subject and johndoe@yahoo.com is your recipient name
  • # echo "your messages" | mutt -s "your subject" johndoe@yahoo.com
    • where -s is for subject and johndoe@yahoo.com is your recipient name
To send email with attachment
  • # echo "your messages" | mutt -s "your subject" -a /path/to/attachment johndoe@yahoo.com
    • where -s is for subject, johndoe@yahoo.com is the recipient name and /path/to/atachment is the path to attachment file
Hope this will be helpful...:)

2 comments:

Bas said...

The "-a file" options should be at the end of the command line (according to manpages). The proper way would be
# echo "your messages" | mutt -s "your subject" johndoe@yahoo.com -a /path/to/attachment

Anonymous said...

thnx a lot bas