Search code examples
linuxemailshellsendmail

Sending a mail from a linux shell script


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?


Solution

  • 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.