How do i write a mail from a script

Hi all,
How do i send a mail using mailx r mail command from a script with the following information along with it
a) the mail should be send to a person with a CC to some other person
b)with a subject
c) with a message.
this mail has to be send withing a script so u cannot pass any command line arguments. I mean to say that based on some condition the command has to be executed with the following things

Thanks in advance.

see his tread:

Hi mib,
Thanks for ur help.I saw the document that u have refered.Most of the things i did'nt understood. By the way is there any way of writing a simple script by using mailx or mail command to achieve my job.
Thanks in advance

try this:


Recieps="one@of3 two@of3 three@of3"
mailx -s "Testing..." $Recieps < /message/text

you can also use sendmail:


CClist="one@of3 two@of3 three@of3"

/usr/sbin/sendmail -t <<EOF

To: $TO
CC: $CClist
From: $FROM
Subject: $Subject

The message


if you have metamail in your system use metasend. this is flexible and more easiest in mail scripting.