Linux – Sending a mail from a linux shell script

emaillinuxsendmailshell

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?

Best Answer

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" your@email.com

man mail for more details.