mailx problem with multiple cc

I am writing a script to send an email of the result of the process but i cannot make the cc work correctly.

RECIP="abc@example.com def@example.com"
CC="ghi@example.com jkl@eaxmple.com"
mailx -s "testing" -c $CC $RECIP < inputfile.txt

Result:

To: abc@example.com; def@example.com; jkl@eaxmple.com
Cc: ghi@example.com
Subject: Testing
< some text here>

The cc is not working correctly on multiple recipient. I tried put the CC inside the double quotes like below but its not sending an e-mail at all.

mailx -s "testing" -c "$CC" $RECIP < inputfile.txt

Any help is greately appreciated.

Try,

mailx -s "testing" -c \"$CC\" $RECIP < inputfile.txt

I also tried that same thing but it just hang :frowning:

try this...

RECIP="abc@example.com,def@example.com"
CC="~c ghi@example.com,jkl@eaxmple.com"
echo $CC >tempfile
cat tempfile inputfile.txt | mailx -s "testing" $RECIP

I agree with Kattoor. The separator for mail address lists is a comma.
(For some strange reason Microsoft use a semi-colon in their user interface).