Problem while sending mail with attachements


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Problem while sending mail with attachements
# 1  
Old 10-06-2006
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

Last edited by RTM; 10-06-2006 at 09:57 AM..
# 2  
Old 10-06-2006
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
# 3  
Old 10-08-2006
Quote:
but i dont think you can attach a file.
no you can...

search the forum please

mailx with attachment
# 4  
Old 10-08-2006
Quote:
Originally Posted by nishant_pathak_
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 !!!
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.
# 5  
Old 10-27-2006
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...
This User Gave Thanks to superdougl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Mail command to send attachements

I tried the below command uuencode data.txt | mailx -s “Test Mail” “mrp@xyz.com” But I get the below error ksh: uuencode: not found. Null Message body; hope that' ok which clearly tell that uuencode utility is not found. Is there any other way to send attachments with mail through... (7 Replies)
Discussion started by: rpm120
7 Replies

2. UNIX for Dummies Questions & Answers

Issues in sending mail with attachements

Hi I am using the below command to send mail from unix with body as well as attachment. But the attachment is in encoded form in the body itself. I am not receiving as attachment: (cat body_success.txt;uuencode Log.txt Log.txt)| mailx -s "success" $ToID I am receiving... (5 Replies)
Discussion started by: pandeesh
5 Replies

3. UNIX for Advanced & Expert Users

problem in sending mail to a group

I am calling a unix script in oracle to send a mail to outlook group using mailx. The cmd looks like this: mailx -s "AA_BBB_" APPostServices@xyz.com APPostServices@xyz.com isa group but the mail is not sent but when i send mail to another group it works fine. What are the things that i... (1 Reply)
Discussion started by: petervuksich
1 Replies

4. Shell Programming and Scripting

problem in sending mail to a group

I am calling a unix script in oracle to send a mail to outlook group using mailx. The cmd looks like this: mailx -s "AA_BBB_" APPostServices@xyz.com APPostServices@xyz.com isa group but the mail is not sent but when i send mail to another group it works fine. What are the things that i... (1 Reply)
Discussion started by: petervuksich
1 Replies

5. UNIX for Dummies Questions & Answers

Problem with sending E-Mail

Im having trouble with sending a file with attachment. The attach file wasn't sent to to the recepient. We tested this manually and it works but with the script it doesn't work. I'm thinking there is a problem with the script. Here is the code: mailto=`/dir/dir2/dir3/GET_EMAIL_ADDR.sh... (9 Replies)
Discussion started by: Iq_zero
9 Replies

6. AIX

Problem sending mail

Everytime i try sending mails using the command line have a reply form the daemon saying : ? 1 Message 1: From MAILER-DAEMON Wed Apr 25 10:42:36 2007 Date: Wed, 25 Apr 2007 10:42:36 -0500 From: Mail Delivery Subsystem <MAILER-DAEMON> To: malarie MIME-Version: 1.0 Content-Type:... (0 Replies)
Discussion started by: Netghost
0 Replies

7. Shell Programming and Scripting

Send Attachements in Mail (CSHELL)

Hi All, Is there any way we can send attachement in a mail from the script using CSHELL. Thanks in Advance. (1 Reply)
Discussion started by: surfsg24
1 Replies

8. UNIX for Advanced & Expert Users

I have a problem in sending mail

Hi, I have a problem in sending mail ...... #!/usr/bin/perl -w $file_length = `cat file.txt | wc -l`; if ( $file_length == 0) {} else { `mail -s "Tool" <mymailid> < file.txt`; } Eventhough i have used `uuencode Mailfile$App_Server$line | mail <mymailid>`;... (2 Replies)
Discussion started by: vijaysabari
2 Replies

9. Shell Programming and Scripting

I have a problem in sending mail

Hi, I have a problem in sending mail ...... #!/usr/bin/perl -w $file_length = `cat file.txt | wc -l`; if ( $file_length == 0) {} else { `mail -s "Tool" <mymailid> < file.txt`; } Eventhough i have used `uuencode Mailfile$App_Server$line | mail <mymailid>`;... (1 Reply)
Discussion started by: vijaysabari
1 Replies

10. Linux

attachements with mail command

Is there any way to send attachments via "mail" command from the terminal? im writing a simple bash script to send my backups to my email address (2 Replies)
Discussion started by: C|[anti-trust]
2 Replies
Login or Register to Ask a Question