Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mailx with uuencode to send mail with Attach and message 1

Status
Not open for further replies.

TyzA

Programmer
Jan 7, 2002
86
BE
Hi,

I'm trying to send a mail with mailx which has to send a fil attached and a message in the body.

To do this I'm using the following line:
(cat <message> ; cat <filename>| uuencode <filename> )| mailx -s&quot;<subject>&quot; <mail address>

But what I end up with is always the same.
I receive my mail (MS Outlook) without the attach.
The mail message is ok BUT the attach is appended to my message like this:

BODY
BODYbegin 666 attach2
M051404-(&quot;D%45$%#2 I!5%1!0T@*051404-(&quot;D%45$%#2 I!5%1!0T@*0514 M04-(&quot;D%45$%#2 I!5%1!0T@*051404-(&quot;D%45$%#2 I!5%1!0T@*051404-( (&quot;D%45$%#2 I#

end

The file I'm trying to attach is a plain txt file (log file).

Also, I can't use other mail programs. It has to be mailx

Thanks for any help.

Tijs
 
I normally do something like this...

/usr/lib/sendmail -f &quot;DailyReport&quot; you@somewhere.com << END
Subject: Log File

`cat /path/to/body`
`cd /path/to/txtfile
uuencode file.txt file.txt`
END
 
I would suggest using a temporary file, e.g:
[tt]
echo This is a message > mailfile
uuencode attach.txt attach.txt >> mailfile
mailx -s &quot;the subject&quot; recipient@mail.com < mailfile
rm mailfile
[/tt]
 
This command always works for me.

filename1 = name on unix box
filename2 = attatchment name on recieving end.


cat filename1 |uuencode filename2|mailx -s &quot;test&quot; email@name.com
 
I use:

mailx -s &quot;Beaster's Node Checkup&quot; mail@email.com < status
 
The problem is that your [tt]<message>[/tt] does not end with a return, so the first part of the uuencoded file, the [tt]begin[/tt] command, doesn't start at the beginning of the line, so it isn't seen as a uuencoded file. If you notice the &quot;[tt]BODYbegin[/tt]&quot;, well the &quot;[tt]begin[/tt]&quot; just needs to start on a line by itself. If you change your command to...
[tt]
(cat <msg> ; echo ; cat <filename>| uuencode <filename> )| mailx -s&quot;<subject>&quot; <mail address>
[/tt]
...it should work.

This is how I do it, which also allows multiple attachments...
[tt]
( cat <<-MSGTXT
Hello,

Please find file1.dat and file2.dat attached.

Regards, Me
MSGTXT
uuencode file1.dat file1.dat
uuencode file2.dat file2.dat
) | mailx -s &quot;Two files attached&quot; person@mail.com
[/tt]
This requires no temp file.

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top