Email sent to multiple user address?

hi all,
This is user that i want sent the email:

Email = allan@gmail.com bruce8899@gmail.com Chris@gmail.com
echo "$dir : $filecount is over the limit $limit " | mailx -s "${SUBJECT}" "${email}"

However it cannot sent to 3 user..only sent to 1 user email address.
Any 1 can help me solve it?

Email="allan@gmail.com bruce8899@gmail.com Chris@gmail.com"

Hi ,
also cannot ..only sent to 1st email address. Other email not function.How?

hi

Can you write your commands in fully here?

And what is your system ?

Hi ,
I write in csh script. I have to set the email address as variable $email.

The script can run if my email variable output only 1 email address :

But if the email variable got 2 or more email address like this:

This email only sent to 1st email address.This is the code sent email :

 mailx -s "${SUBJECT}" "${email}"

Does it work if you have the 2nd and susbequent email addresses in the cc list?

EMAIL=allan@gmail.com"
CC="bruce@gmail.com steve@gmail.com"
 
mailx -s "${SUBJECT}" -c "${CC}" ${EMAIL}

Some implementations of mailx only support multiple addresses in the cc list.

hi Chubler_XL,

I must done it without sent to cc.

You don't mention the O/S but most "mailx" versions will need one invocation per recipient.

for email in "allan@gmail.com" "bruce8899@gmail.com" "Chris@gmail.com"
do
    echo "$dir : $filecount is over the limit $limit " | mailx -s "${SUBJECT}" "${email}"
done

There are more complicated methods of processing a list of recipients by using mailx tilde commands but it still needs one invocation of "mailx" per recipient.

I think using a comma between the email addresses will do the work.

Hi
I still cannot sent out the email to multiple user . This is my man mailx

 Send mode:
      mailx [-FUm] [-s subject] [-r address] [-h number] address ...

    Receive mode:
      mailx -e

      mailx [-UHLiNn] [-u user]

      mailx -f [-UHLiNn] [filename]

    Obsolescent:
      mailx [-f filename] [-UHLiNn]

while how to set it sent to multiple user ?

Ahh the man helps, so your mailx does support multiple address. Just use:

emails="allan@gmail.com bruce8899@gmail.com Chris@gmail.com"

echo "$dir : $filecount is over the limit $limit " | mailx -s "${SUBJECT}" ${emails}

Notice no quotes around the ${emails} this will expand each email to a seperate parameter (as the "..." in the usage show your mailx requires).

I try liao....it only sent the email to 1 user only...

Do you have the quotes around the assignment?

Your original post shows:

Email = allan@gmail.com bruce8899@gmail.com Chris@gmail.com

But have you tried:

email="allan@gmail.com bruce8899@gmail.com Chris@gmail.com"

Yup , i try both method....also same..only sent to 1user....any nothing error come out.

Do you get the same result if you run mailx from command line? eg:

 echo "Test message" | mailx -s "Command line test" allan@gmail.com bruce8899@gmail.com Chris@gmail.com

If so: I'd start to think the other reciepents are rejecting due to other issues (relaying, SPAM filters, etc) swap order and see if it's always the 1st email that gets thru.
If not: Check your script to ensure "email" is not getting reset somewhere (perhaps echo it's value just before the mailx command).

If you still have not joy consider having you sysop setting up a mail alias in /etc/mail/aliases

Erm..can already i do mistake .Thx very much