Sending mail with attachment

Hi,

I am using Sun solaris OS unix server
I am trying to send mail with an attachment using below script

cat test.txt;uuencode test.txt test.txt|mailx -s "$subject" someone@somewhere 

I m getting mails but with no attachment.

Hence i manipulate the script as below and i am getting the mail with attachment

cat test.txt;uuencode test.txt test.txt|mail  someone@somewhere 

But my question is why i am not getting attachment with earlier code.Can anyone pls help.

Not sure this would be the only problem here, but you do need to group your output together.

Assuming your test.txt has all your To:, From:, Subject: and body text and sendmail is your mail agent, can you try this using the parenthesis?

(cat test.txt;uuencode test.txt test.txt ) | sendmail -t 

I don't have a Solaris server, but this works for me on hp-ux.

uuencode <attachment> <attachment> | mail user@domain.com

I usually do it without the cat <file>

update: you can do this:

uuencode <attachment> <attachment> | mail -s "subject" user@domain.com </path/to/text