LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I send mail from inside a script? (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-send-mail-from-inside-a-script-239581/)

bruno buys 10-06-2004 06:34 PM

How do I send mail from inside a script?
 
How do I send mail from inside a script?


Thanks!

Samsara 10-06-2004 06:45 PM

You mean email? Use mailx.

HTH,

Samsara

bruno buys 10-06-2004 07:07 PM

Does mailx use the local send mail agent? Can I point it to another?

Dave Kelly 10-06-2004 07:57 PM

It could be something like this: (thanks to CAF Johnson for showing me this.

#!/bin/sh

messagefile=$1 ## contains the message to be sent
[ -f $1 ] || { echo "$messagefile does not exist"; exit 5; }

while read email
do
mail -s "Club newsletter" $email < $messagefile
done
## EOS ##

email contains the e-mail address.


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