Artificial intelligent assistant

Echo to file clashes with mailutils After installing ssmtp and **mailutils** , writing to a file with 'echo' tries to send me an email to username@hostname. For example: Sending mail with mailutils: `echo "Body text here." | mail -s "Subject text here." sendto@email.com` and I use: `echo "log content" > logfile.txt` to write content to a log file. The problem is that when I want to wite to a log file, I get an deliverable email from Gmail saying username@hostname is unreachable, meaning that it interferes with mailutils. I this a known issue with mailutils which needs a workaround or fix and how can I approach it?

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

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 60efbe7be709c6164fc9b9233f67bdc1