how to send contents of a file to email as a message

i have a file new1.txt
i want to send the contents of that file as a message to email ali@sms.com

i m using ksh script.........

plz help me

Hey,

use following ...

Subject="mailing you buddy.."
MAIL_RECIPIENTS="ali@sms.com, xyz@abccom"

cat new1.txt | mailx -s "$Subject" $MAIL_RECIPIENTS

Thanks

actually i have a file

#!/bin/ksh

echo " ************************************ " >> perst
echo " The following apps are running currently indicated by their number" >> perst

for i in Archiver1 Cleaner1 Archiver2 Interpolation DBMaint ImportAdapter_CC Extrapolation ZeroConsumptionReport DBSyncListener TnsProvAdapterCheckConfig
do
count=0
count=`ps -aef | grep java | grep $i | wc -l`
echo $i $count >> perst
ps -aef | grep java| grep $i >> /tmp/new1.txt
done
echo " ********************************************** " >> perst
mail -s "Plz find the attachment for the currently Running application" naveed@cap.com < /tmp/new1.txt
Hi,
This Attachment contains the list of all the Applications Running Currently on
mdcaedn03.tu.com

Thanks
Ali Naveed
-------------------------------------------------------------------------can u tell me why i m not getting the content of file new1.txt in my mail

Hey,

Above Boldfaced, shows redirection but whats the command in it ??
it should be ..
mail -s "Plz find the attachment for the currently Running application" naveed@cap.com < cat /tmp/new1.txt

Otherwise use pipe as I gave the example previously..

cat /tmp/new1.txt | mail -s "Plz find the attachment for the currently Running application" naveed@cap.com

Try this one..hope it'll work. :slight_smile:

instead of using the mail command, use mailx.

it should be like this:

mailx -s "Plz find the attachment for the currently Running application" naveed@cap.com < /tmp/new1.txt

I just checked the functionality of this in my unix environment:

echo "Hi hw are you" > /tmp/new1.txt
mailx -s "kshfks" myid@domain.com < /tmp/new1.txt

And I got the mail in my domain

thanks now i m getting the message but after that i have written some messages
-------------------------------------------------------------

Hi,
This Attachment contains the list of all the Applications Running Currently on
mdcaedn03.tu.com

Thanks
Ali Naveed
-------------------------------------------------------------------------------
above one its not displaying, can u tell me the syntax