Operating System - HP-UX
1753928 Members
8937 Online
108810 Solutions
New Discussion юеВ

Re: mailx question - both text in body and attachment

 
SOLVED
Go to solution
Daniel Dumont_1
Advisor

mailx question - both text in body and attachment

I am looking for a simple way to have mailx email a message with both text in the body of the email and an attachment.

I am familiar with this to get attachment
ux2dos file | uuencode file | mailx -m -s "subject" emailaddress

I am familiar with this to get text in body
mailx -s "subject" emailaddress < textinbody

Any help would be greatly appreciated.
Will assign points for solutions!!
7 REPLIES 7
Patrick Wallek
Honored Contributor
Solution

Re: mailx question - both text in body and attachment

I couldn't get it to work using mailx, but sendmail worked.

# (echo "Subject: test" ; cat file ; uuencode file file) | /usr/sbin/sendmail you@domain.com

Try it and see if it works for you.
Steven E. Protter
Exalted Contributor

Re: mailx question - both text in body and attachment

Shalom,

Won't work with mailx

http://www.hpux.ws/?p=7

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Daniel Dumont_1
Advisor

Re: mailx question - both text in body and attachment

Thanks for your help.
Points assigned.

The sendmail solution worked in my situation.
Will assign points for solutions!!
Daniel Dumont_1
Advisor

Re: mailx question - both text in body and attachment

On the same subject
Maybe I should put this question in the scripting forum.

At the same time as emailing, I need to replace some characters in "infile".

The below example is doing what I want.
Except I would like to eliminate the creation of "outfile" on the disk.
I am hoping to do in the one command without the "outfile" file ever getting created on disk.
This example gives me "anotherfile" text in the email body and "attfile" as the attachment.

(echo "subject: subjecttext"; tr -d "\036" < infile | tr "\047" "\012" > outfile; cat anotherfile; uuencode outfile attfile) | /usr/sbin/sendmail emailadd
Will assign points for solutions!!
Dennis Handly
Acclaimed Contributor

Re: mailx question - both text in body and attachment

>I am hoping to do in the one command without the "outfile" file ever getting created on disk.

It may not be worth the complexity if you don't understand the changes. Any reason you care about this extra file?

(echo "subject: subjecttext";
cat anotherfile;
tr -d "\036" < infile | tr "\047" "\012" |
uuencode attfile) | /usr/sbin/sendmail emailadd
Daniel Dumont_1
Advisor

Re: mailx question - both text in body and attachment

Thanks Dennis.

Worked perfectly.
Exactly what I wanted.
Will assign points for solutions!!
Steven Schweda
Honored Contributor

Re: mailx question - both text in body and attachment

Of course, if something ever goes wrong with
the long pipeline, debugging anything
'without the "outfile" file ever getting
created on disk' may be difficult. Sometimes
those pesky temporary files can be handy.