The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Email sending attachement with two file comparision orabalu Shell Programming and Scripting 4 01-26-2009 01:12 PM
Sending Attachments Through mailx vrk1219 HP-UX 7 01-21-2009 03:18 PM
sending mail using mailx command manas6 UNIX for Dummies Questions & Answers 5 12-08-2008 10:20 AM
sending mail through mailx pvamsikr Shell Programming and Scripting 3 07-13-2008 10:56 PM
sending email from mailx legato UNIX for Dummies Questions & Answers 1 11-04-2004 10:31 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 76
Sending attachement using mailx

Hi

I tried reading docs from this forum and googled it...but i couldnt get the answer for attaching a document in mail.

I need it to be the actual attachement not adding the content of the file to the body of the mail..

i used uuencode ...to encode the file but it is coming as a junk character in the mail body (actual mail received)


Code:
uuencode /tmp/tmp-mail.txt attach.txt | /usr/lib/sendmail -t -n -f root aemunathan.r@gmail.com


uuencode /tmp/tmp-mail.txt attach.txt | mailx -s "Test attachment" aemunathan.r@gmail.com

in a script taken from this forum i used this way.

Code:
#!/usr/bin/ksh

export MAILTO="aemunathan.r@gmail.com"
export SUBJECT="Mail Subject"
export BODY="/tmp/tmp-mail.txt"
export ATTACH="/aemu/CMW_A02_2.sql"
(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat $BODY
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: base64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 uuencode --base64 $ATTACH $(basename $ATTACH)
 echo '---q1w2e3r4t5--'
) | /usr/lib/sendmail $MAILTO

this resulted in uuencode illegal option base 64

another script i tried is

Code:
#!/bin/ksh

export TOADDR=aemunathan.r@gmail.com    
export FROMDIR=/aemu

cd ${FROMDIR}

( cat <<-TEXT
Hi,

Please find enclosed all of the text files found
in the directory ${FROMDIR} as of $(date).

Sincerly, $(grep root  /etc/passwd| cut -d: -f5)
TEXT

for FNAME in *.sql
do
   uuencode ${FNAME} ${FNAME}
done
) | mailx -s "${FROMDIR}/*.sql as of $(date)" ${TOADDR}

this resulted in junk charaters in the body of the mail

Any one help me out what mistake am doing here....

Thanks
Aemu
  #2 (permalink)  
Old 09-28-2009
uthay85 uthay85 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 11
uuencode $ATTACH $ATTACH |mailx -s "SUBJECT" $MAILTO

Please try this one.....
  #3 (permalink)  
Old 09-28-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 76
Hi

Mail sending is ok but not the attachement.

am getting junk like this in the body of the mail...

Quote:
begin 644 /aemu/CMW_A02_2.sql
M1%)/4"!404),12!C;7=?03 R7W1A>#L-"F-R96%T92!T86)L92!C;7=?03 R
M7W1A>"!A<PT*4T5,14-4(&)I;&Q?<F5F7VYO+%-532A!34]53E0I+S$P,"!S
M97)V:6-E7W1A>" @1E)/32 -"F%R8F]R+D))3$Q?24Y63TE#15]$151!24Q
M=&-S,VQI;FL-"E=(15)%($))3$Q?4D5&7VYO(&EN("AS96QE8W0@:6YV;VEC
M95]N;R!F<F]M(&-M=U]!,#(I#0I!3D0@4U5"5%E015]#3T1%(#T@+34-"BTM
M04Y$(%-50E-#4E].3SP^, T*1U)/55 @0ED@8FEL;%]R969?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#15].3SUE+D))3$Q?4D5&7TY/*"LI(&%N9 T*82Y)
M3E9/24-%7TY//68N0DE,3%]2149?3D\H*RD@86YD( T*82Y!0T-/54Y47TY/
F/6<N04-#3U5.5%].3PT*;W)D97(@8GD@82Y!0T-/54Y47TY/#0I/

end
  #4 (permalink)  
Old 09-28-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,945
Not all versions of mailx support MIME attachments.

Check to see if your version of mailx has a -m command line option. It it has, use that option to create a MIME attachment.

If not, you could use utilities such as mpack/munpack or mmencode to create a MIME attachment.
  #5 (permalink)  
Old 09-28-2009
aemunathan aemunathan is offline
Registered User
  
 

Join Date: May 2008
Posts: 76
Hi

that also i tried initially. with -m option...my server does not support it...

do i need to install mpack...

i tried searching *encode* in my server from root directory....found only uuencode...nothing else....
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0