Shell script to send email

user517400 picture user517400 · Jan 11, 2011 · Viewed 289.7k times · Source

I am on linux machine and I monitor a process usage. Most of the time I will be away from my system and I have access to internet on my device. So I planned to write a shell-script that can mail me the output of the process.

Is it possible?

If so how to make a shell-script send me mail?

Please provide a snippet to get started.

Answer

trojanfoe picture trojanfoe · Jan 11, 2011

Yes it works fine and is commonly used:

$ echo "hello world" | mail -s "a subject" [email protected]