Are you doing something like this?
echo "log content" > logfile.txt | mail -s "Subject text" sendto@email.com
If so, it's no wonder that it won't work - you're already redirecting `echo`'s output to a file, you can't also pipe it to `mail` without using a program like `tee`.
`tee`'s entire purpose is to (from the man page):
> tee - read from standard input and write to standard output and files
Note: if you want to append to `logfile.txt` rather than overwrite it completely, use `tee -a logfile.txt`. See `man tee`.
So, to save to a logfile AND pipe into mail, try this:
echo "log content" | tee logfile.txt | mail -s "Subject text" sendto@email.com
Alternatively, you can redirect to a logfile and then use `<` to redirect `mail`'s stdin to be the logfile, like so:
echo "log content" > logfile.txt
mail -s "Subject text" sendto@email.com < logfile.txt