LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Sending an automatic mail using bash + mail (https://www.linuxquestions.org/questions/linux-software-2/sending-an-automatic-mail-using-bash-mail-84151/)

Minuteman 08-21-2003 08:50 AM

Sending an automatic mail using bash + mail
 
Hello, I want to make a shell (bash) script that automatically sends me a message without an user interaction.

I tried: mail root -s "Hello you"

but then the program absolutely wants that I hit 2 times on the enter key... is there a way to tell bash to make a "return to the line" or a better way to do this?

m0rl0ck 08-21-2003 09:05 AM

echo hello|mail -s test "Hi dere"

and hello will appear in the message body, you can also do this with cat to read a file or just about any prog that outputs text that youd like mailed


EDIT: should have been echo hello|mail -s "Hi dere" user@host

I can cut and paste much faster than I can think :)

unSpawn 08-21-2003 09:14 AM

AFAIK it's "cat <sometext>|mail -s "<subject>" <mail@address>"
Btw, you can also send MIME attachments using "mpack" instead of "mail".

Minuteman 08-21-2003 09:15 AM

It works great so, thank you all for your quick answers :-)

lfur 08-21-2003 12:49 PM

A bit late but ...
mail some@address.here < textfile


All times are GMT -5. The time now is 07:10 PM.