In UNIX-like system, mail is the common tool use to sending mail and reading mail. It is simple and easy to use. To read mail for your account just type:
or if you want read in mail in specific dir
mail -f /var/mail/user
to send a mail:
mail user < /tmp/file.log
echo "This is sample mail" | mail -s "Sample" user
'-s' switch is use to specify the subject you want to send.
How about sending a attachment? This will need another program call 'uuencode' which will encode the binary to a ASCII code:
uuencode file.bzip2 file | mail user
'uuencode' is will take 2 argument to work, the 1st is file name need to encode and the 2nd argument just a redundancy argument to allow 'uuencode' to send to stdout (indeed the screen). But the problem is that the file send out would be not able to download, so 'mutt' come to rescue ;p
'mutt' also as easy as 'mail', to read mail just enter:
mutt -f /var/mail/user
but 'mutt' is much easy to use to send a attachment:
mutt -s "Sample" -a /file/path/file email@example.com < /tmp/msg
same like 'mail' : '-s' is the subject switch to specify a subject of the mail, '-a' is the attachment want to send. The last argument is the email address want to send, for the < /tmp/msg is the message body you want to sent to firstname.lastname@example.org. If the /tmp/msg is not specify 'mutt' will wait for user to enter the message. /tmp/msg must be a file, so what I think is 'mutt' will only take in the file not any I/O input. If you don't want to use the 'mutt', there have a another way to send a attachment using 'sendmail'. But if using 'sendmail' you will need to specify the MIME (Multipurpose Internet Mail Extensions) standard header. For more detail can go to Sending Attachment using mutt and sendmail.