Problem while sending mail with attachements

Hi All,

I am using mailx command in shell script to send mail with output files as attachment to my email id.

When my colleague is running the shell script (script code mentioned below), he is getting the mail but without attachment. Attachment is appeared as junk characters in mail body.

But from my login the same script is running fine with the recipient mail id in script as xyz@abc.com and I am getting the mail with attachment and correct output. Also, when I send mail to anybody else then also they are getting junk characters in mail body and I am getting mail with correct output !!!

Script Code to send mail

ATTFILE1=`echo update_error_${date_rcvd}.log`
ATTFILE2=`echo update_reject_${date_rcvd}.log`
ATTFILE3=`echo update_unused_${date_rcvd}.log`
ATTFILE4=`echo update_log_${date_rcvd}.log`
ATTFILE5=`echo filter_null_unused_${date_rcvd}.log`
ATTFILE6=`echo highest_noncancelled_error_${date_rcvd}.log`
ATTFILE7=`echo highest_noncancelled_unused_${date_rcvd}.log`

(cat mail_body.txt; uuencode ${ATTFILE1} ${ATTFILE1}; uuencode ${ATTFILE2} ${ATTFILE2}; uuencode ${ATTFILE3} ${ATTFILE3}; uuencode ${ATTFILE4} ${ATTFILE4}; uuencode ${ATTFILE5} ${ATTFILE5}; uuencode ${ATTFILE6} ${ATTFILE6}; uuencode ${ATTFILE7} ${ATTFILE7}) | mailx -s "Service DN Feed Processed2: ${i}" 'abc@xyz.com'

Any help would be of great appreciation.

Looking forward to your kind reply.

Nishant Pathak
email: Email addresses are not allowed - read the Rules

you should have no problem pumping a file to an email. but i dont think you can attach a file. you can take a files contents and mail it like this

mailx -s "Subject" < textfilledfile.txt youremail@mail.com

in my experience, not a good idea to send non-text files through mailx. you should modify your script in accordance with the above syntax. Instead of echo'ing, just pump the file to the email with '<'.

Hope that helps.

-Sowser

no you can...

search the forum please

mailx with attachment

Since you are getting the correct output, then you know that your script works. However, not all email clients can cope with uuencoded attachments. You will have to attach files to your message using MIME, so perhaps consider using mutt.

If the recepient is an exchange server, put '-m' in front of the recepint. It happens in company, if no '-m', the recepient will receive a junk character in messge body.

You may try the following command :

(echo "\nPlease see the attachment for details.";awk 'sub("$", "\r")' attach_file | uuencode attach_file) | mailx -s "YOUR SUBJECT" -m recepient@aaa.bbb.com

Hope this will help...