Sending a mail from a linux shell script

appshare.co picture appshare.co · Mar 1, 2011 · Viewed 406.1k times · Source

I want to send an email from a Linux Shell script. What is the standard command to do this and do I need to set up any special server names?

Answer

Francesco Laurita picture Francesco Laurita · Mar 1, 2011

If the server is well configured, eg it has an up and running MTA, you can just use the mail command.

For instance, to send the content of a file, you can do this:

$ cat /path/to/file | mail -s "your subject" [email protected]

man mail for more details.