script to send mail from unix??

Hi all,

I wrote a shell script to send a mail, it is not showing any errors but i didn't receive any mail

#!/bin/ksh

. ./set_mail_details.ksh

echo 'In script'
subject=$1
echo '\nsubject'
echo $1
echo "$subject" | sed 's/~/ /g' | read sub
body_of_email=$2
echo '\nBody'
echo $2
echo '\nMail List'
to_list=$3
echo $3
echo "$body_of_email" | sed 's/~/ /g' | read body
(echo "$body";echo '\n';cat U.CUE_CPM )| mailx -s "$sub" -r some\_address@some_mail.com "$to_list"
if [ $? -eq 0 ]
then
echo "Mail is Sent"
else
echo "Mail is not sent(In script)"
fi

output:
$ send_mail.ksh hi test some\_address@some_mail.com
In script
subject
hi
Body
test
Mail List
some\_address@some_mail.com
Mail is Sent

can any one please help me what is wrong in my script.

Deepaknbk,
I tested your script several times and it worked every time,
except when I placed the wrong e-mail address either in the
receiver or with the '-r' option.

Make sure your e-mail addresses are correct.

Good luck!

can anybody pls help me in writing a shell script to send a automatic email to a team if the mount point size increases to 70mb. for example consider /u01 mount point in a linux platform using bash shell. pls do help.

thanks
tahseen

Hi deepa
If you need other way to coding in Unix to send mail , I can help you .

~Sakthifire

thanks for replying .yeah sure. any coding using any shell type is ok.

#! /bin/ksh
#By Sakthifire
#TO send email
#regarding disk space

export FROM_ADDR="Sakthifire"
export TO_ADDR="emailid@mail.com"
CUR_DIR=/home/mail

send_mail()
{
for addr in $TO_ADDR
do
echo "From: $FROM_ADDR" > $CUR_DIR/mail.txt
echo "To: $TO_ADDR" >> $CUR_DIR/mail.txt
echo "Subject: Sending email">> $CUR_DIR/mail.txt
# here you can implement your logic to check the size of the folder
# redirect it to a mail.txt
echo "" >> $CUR_DIR/espmail.txt
echo "This is a automated email.Please don't reply to it ." >>$CUR_DIR/mail.txt
sendmail $addr < $CUR_DIR/espmail.txt
done
rm mail.txt
}
send_mail

----------------------------------------------------------------------------------------

Note : Please change the CUR_DIR , FROM_ADDR & TO_ADDR as per your need . You can have multiple sender email ids seperated by a space in TO_ADDR .

~Sakthifire

thank yous so much. Let me implement this!!!
thanks
tahseen

thanks a lot.. this script really worked