A One-Line Technique for Mailing a File's ContentsIf you have a file called apple.txt and you want to mail its contents as a mail message to firstname.lastname@example.org with the subject line "unix-asg1," you can do this at the Unix prompt like this:
mail -s "unix-asg1" email@example.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 firstname.lastname@example.org 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" email@example.com