A One-Line Technique for Mailing a File's Contents
If you have a file called apple.txt and you want to mail its contents as a mail message to nobody@foo.com with the subject line "unix-asg1," you can do this at the Unix prompt like this:
mail -s "unix-asg1" nobody@foo.com < apple.txt
This is very useful if you are a Unix shell and you don't want to enter your mail program.
Note: this may not work on all Unix systems. If this doesn't work, follow this example to mail a file's contents.
A One-Line Technique for a Mailing a Short Message
You can use the echo command to send a short text message in one line. Say you want to send the message "City Hall 1pm" to nobody@foo.com with the subject line "meeting today" by email. You can do it at the Unix prompt like this:
echo "City Hall 1pm" | mail -s "meeting today" nobody@foo.com