Use tee command to send output to a file and email

Problem

You would like to send the error output from a command or a script to both an error file and an email.

Solution

By using tee, you could do the following: