Operating System - HP-UX
1833777 Members
2430 Online
110063 Solutions
New Discussion

Re: Send email with body and attachment

 
SOLVED
Go to solution
yyghp
Super Advisor

Send email with body and attachment

I tried to send email by using "mailx" with body and attachment:

# uuencode abc.tar abc.tar | mailx -m -s "send tar attachment" email@yahoo.com < body.txt

But I can only get email with body, but no attachment!

However, if I tried this way:
# uuencode abc.tar abc.tar >> body.txt
# mailx -m -s "send tar attachment" email@yahoo.com < body.txt
then I can get email with both body and attachment

Why? I'd like to send email with one single command line, how can I use "pipe" to do this?
Thanks!
8 REPLIES 8
Geoff Wild
Honored Contributor

Re: Send email with body and attachment

Try doing it with mpack:

http://hpux.ee.ualberta.ca/hppd/hpux/Users/mpack-1.6/

The attach like so:

mpack -s test -d test.doc you@yourdomain.com

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.
Simon Hargrave
Honored Contributor
Solution

Re: Send email with body and attachment

How about: -

( cat body.text ; uuencode abc.tar abc.tar ) | mailx -m -s "send tar attachment"
Rita C Workman
Honored Contributor

Re: Send email with body and attachment

...the thread is old, but maybe you can find some helpful information.

One tool I like to use to easily send attachments is the [include] command :

http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x41950559ff7cd4118fef0090279cd0f9%2C00.html&admit=716493758+1091120147036+28353475

Or you can search for something like MIME attachments and you should get some other things...

Rgrds,
Rita
yyghp
Super Advisor

Re: Send email with body and attachment

Thanks Simon, it works fine!
yyghp
Super Advisor

Re: Send email with body and attachment

thanks guys!
Mel Burslan
Honored Contributor

Re: Send email with body and attachment

I have the same problem using mailx. I used to be able to send this but due to some *feature upgrades* on my mail relay servers most probably, which is M$ exchange by the way if you have not guessed it, the feature is not working for a long time.

Now I resorted to less elaborate sendmail to do the same thing as follows

uuencode a.txt a.txt | sendmail user@domain.com

I know I do not get the subject line but I can sacrifice that much in my humble opinion instead of figthing with exchange admins.

I have made a header comparison between the messages received by my outlook client from these two commands:

uuencode a.txt a.txt | sendmail user@domain.com

uuencode a.txt a.txt | mailx user@domain.com

and I saw that, latter command, i.e., mailx, inserts these headers into the message, which I presume causes the attachment showing as plain text:

Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I think exchange server stopped treating these headers as attachments at some point during the past year for me.
________________________________
UNIX because I majored in cryptology...
Simon Hargrave
Honored Contributor

Re: Send email with body and attachment

Mel, you can use the "-m" option in mailx to stop it sending the Mime headers.
Mel Burslan
Honored Contributor

Re: Send email with body and attachment

Simon,

Big thanks...

Now it started working again with

uuencode a.txt a.txt | mailx -s "attached file" -m user@domain.com

now it comes with attachement and with a subject line.

Cheers...
________________________________
UNIX because I majored in cryptology...