1820473 Members
3242 Online
109624 Solutions
New Discussion юеВ

mailx and attachments

 
SOLVED
Go to solution
Fred Martin_1
Valued Contributor

mailx and attachments

I know this has been discussed before but I can't find the info I need, so here goes.

I have a MS Word document which I need to mail to a user as an attachment. I need to use mailx in a script.

The first step I did was to uuencode the document:

uuencode word.doc word.doc > word.enc

The I emailed it:

mailx -s "here is the doc" user < word.enc

However, the thing shows up as text in the body of the message, i.e.:


Here's the document Fred.
begin 666 26918877.doc
M;F%M92`@("`Z($9R960@36%R= ... etc


I checked, it's not the users mail program as he receives other Word docs OK.

Seems to have something to do with MIME which I know nothing about.

Can someone give me some direction please?
Fred
fmartin@applicatorssales.com
16 REPLIES 16
Pete Randall
Outstanding Contributor

Re: mailx and attachments

Fred,

See Paula's answer in this thread:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x99da35067c18d6118ff40090279cd0f9,00.html


She doesn't use mailx, but sendmail should do the job for you.


Pete

Pete
Ramkumar Devanathan
Honored Contributor

Re: mailx and attachments

Fred,

@ google = link below

http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x720f36e69499d611abdb0090277a778c,00.html

See if it helps.

- ramd.
HPE Software Rocks!
Geoff Wild
Honored Contributor

Re: mailx and attachments

Get mpack - works great:

mpack/munpack version 1.5 for unix

Mpack and munpack are utilities for encoding and decoding
(respectively) binary files in MIME (Multipurpose Internet Mail
Extensions) format mail messages. For compatibility with older forms
of transferring binary files, the munpack program can also decode
messages in split-uuencoded format.

http://hpux.ee.ualberta.ca/hppd/hpux/Users/mpack-1.5/readme.html

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
steven Burgess_2
Honored Contributor
Solution

Re: mailx and attachments

Hi Fred

Here's a sendmail script

#!/usr/bin/sh

export EMAIL_TO=
export EMAIL_FROM=
export EMAIL_SUBJECT="subject of e-mail"
export EMAIL_BODY=/etc/issue
export FILE_NAME=/etc/passwd.txt
export ATTACHED_FILE=/etc/passwd

{
echo To: $EMAIL_TO
echo From: $EMAIL_FROM
echo Subject: $EMAIL_SUBJECT
echo 'MIME-Version: 1.0'
echo 'Content-type: multipart/mixed; boundary="xxxxyyyzzqzzyyyxxxx"'
echo '--xxxxyyyzzqzzyyyxxxx'
echo ''
cat $EMAIL_BODY
echo '--xxxxyyyzzqzzyyyxxxx'
echo 'Content-Disposition: attachment; filename="'$FILE_NAME'"'
echo ''
cat $ATTACHED_FILE
echo '--xxxxyyyzzqzzyyyxxxx--'
} | /usr/sbin/sendmail $EMAIL_TO

HTH

Steve
take your time and think things through
Rita C Workman
Honored Contributor

Re: mailx and attachments

Well mailing attachments (even MSWord, Excel or anything) is one of my favorite things..

Here's an old email that refers to using the 'include' statement. And it works great in a script sending 1 file or a dozen files.

The thread refers to some info on a 10.2 system...but I have boxes already at 11i and the same script works just fine.

Enjoy:
http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0x41950559ff7cd4118fef0090279cd0f9,00.html

Rgrds,
Rita
Fred Martin_1
Valued Contributor

Re: mailx and attachments

Steve,

That's it exactly. That does work. So it does have something to do with MIME. Can I ask, the MIME parameters you set seem arbitrary, should I ask for detail or let it pass :)

Fred
fmartin@applicatorssales.com
Fred Martin_1
Valued Contributor

Re: mailx and attachments

Well, I say that's it but now I'm not sure. If the document is uuencoded, it still shows up as text as I show above...I tried passing a raw MS Word doc without uuencoding it, got errors when trying to open the attachment in Windows. I'm going to work with this a bit and post again here, but if you can help let me know.

Can you tell me the difference between the variables FILE_NAME and ATTACHED_FILE ??

Fred
fmartin@applicatorssales.com
Rita C Workman
Honored Contributor

Re: mailx and attachments

Fred,

Have you tried the threads that talk about using 'include' command. Try it...you might like it...

/rcw
Fred Martin_1
Valued Contributor

Re: mailx and attachments

Rita, yes I did. Both sendmail and mailx just send the include line as the body of the message. We don't use elm so I'm not sure it will help me.
fmartin@applicatorssales.com
Fred Martin_1
Valued Contributor

Re: mailx and attachments

I feel as though I'm almost there. The MIME stuff does force the file to be a clickable attachment, which is what I want. It definitely gets the document out of the body of the message.

Now the problem is, if it's a uuencoded document, passed as somename.doc, MS Office opens it but it still is uuencoded.

I tried using an actual Word document, not uuencoded, and got errors when Word tried to open it.

Fred
fmartin@applicatorssales.com
steven Burgess_2
Honored Contributor

Re: mailx and attachments

Hi Fred

I think that was an example from a test

export FILE_NAME=/etc/passwd.txt
export ATTACHED_FILE=/etc/passwd

The FILE_NAME is the name of the attachment and the ATTACHED_FILE is as described. So essentially the same

As far as MIME is concerned , i'm not sure

HTH

Steve

take your time and think things through
Geoff Wild
Honored Contributor

Re: mailx and attachments

Download mpack - I just tested it with a word document - it works fine....

format is:

mpack -s subject test.doc email.address

Trust me, it's the best thing since sliced bread :)
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Rita C Workman
Honored Contributor

Re: mailx and attachments

Fred,

mailx is a messaging system.
sendmail and elm are true electronic mail systems.

Have you given elm a try??

/rcw

Fred Martin_1
Valued Contributor

Re: mailx and attachments

Geoff, Rita:

I am helping a vendor debug a procedure they use to deliver documents via email. I have an interest because I'm one of their customers with issues - if I can nail this down it'll fix my problem and possibly help them.

They have multiple OS's in their user base, and I can't control which mailer they use - hence I'm trying to find something that uses mailx if possible, sendmail as a fallback.

Fred
fmartin@applicatorssales.com
Fred Martin_1
Valued Contributor

Re: mailx and attachments

I'm not sure but I think I'm on to something. The vendor says they uuencode the document prior to sending it. Are there MIME parameters for uuencode? I've found some hints of that just by browsing the web...

If there is then Steve's script with MIME parameters may work.

For example, is there a Content-type for uuencoded docs?
fmartin@applicatorssales.com
steven Burgess_2
Honored Contributor

Re: mailx and attachments

Hi Fred

Found these for you

sendmail: How to send attachments; Use uuencode (or mime)

http://www4.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000062943010

Here's the docid from the info that I provided

http://www4.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000062684425

HTH

Steve
take your time and think things through