Tuesday, 6 March 2012

Mail Command Examples

mail [-t] [-w] [ -m message_type ] recipient

The Mail Command is a good way (not the only way) of sending/receiving emails via the console.

Root is required for this:
mail someone@somewhere.com

This command will set up the email, it will then ask you for a subject, CC's and message.
once your done You need to type . (dot) to send the email. Then Enter.
It's better if you use the following command:

mail -s "subject" too@somewhere.com -- -r "from@somewhere.com" -f </path/to/a/file>

This command will send an email with a subject to an address from the address specified, the
-f </path/to/a/file> is the file which contains the information,in my case an error log.

this can be shorted to:
mail -s "subject" someguy@someplace.com < atextfile.txt

I often find myself using this command instead, its quicker to type...I should really make a script to do all this for me.

No comments:

Post a Comment