Using mailx to send email to multiple users.

Hi,

I am using the mailx command to send email to multple users. The command works fine when i am sending mail to a single user but when i insert multiple email ids inside the quote it does not work. All the email ids are coming from a property file.Please have a lookt at the property file and the script below below.

xyz.ini
MAILLIST='priyaksingh@rediffmail.com,reahksingh@yahoo.co.in'

script
EMAIL=`grep "MAILLISt=" /xyz.ini | cut -f2 -d=`; export EMAIL
....
....
....

mailx -s "Hi" ${EMAIL} <<! Hi
!

Please do let me know about the exact command that will send email to multiple users.

Try using the forum search feature.

How to send mail to multiple users ???

Thank You Vino. the solution works fine untill the same email ids are assigned to a variable and this list is coming from a property file.

My Property File.
List="receip@xyz.com, receip2@xyz.com"

My Script
MailList=`grep "List=" /propertyfile.ini | cut -f1 -d"+"`
export MailList
mailx -s "Hi" $MailList < text.msg

The above code fails. help me out its urgent. :confused:

The problem is how you define the $Maillist variable. Try running with set -x if using ksh.

Perhaps you could post your real code here. Your "properties" file is either called xyz.ini
or propertyfile.ini and either begins with "List=" or "MAILLIST=".

Hey Priya,
Simply I see only problem to this and that is "," in your mail list. Try to remove comma from mail list and separate the email ids by space and hope you should be all set.

Other wise you could just use sendmail command with "," separated email ids.
Syntax for the sendmail.

LOGNAME=`whoami` #If mail couldnot be send, it will bounce on this account
MailList=${Mail_File_Path}/Mail_List.txt
MAILTO=`cat $ MailList `
echo "From: $LOGNAME\nTo: $MAILTO\nSubject: $SUBJECT" > $mail_body_file

echo "
$SUBJECT.

Regards,
$LOGNAME" >> $mail_body_file
echo ".\n" >> $mail_body_file
#Mail will not be sent to anyone if "." does not appear in first column of th

/usr/lib/sendmail -t -oi < $mail_body_file

Don't forget to add . at the last like I used here with echo. It is mandatory.
Here you can use To,CC,BC, subject attachement ect. Its almost identical to outlook mail so you can use all the facilities what ever you can see in your outlook on windows.

Regards,
Manish Jha