Operating System - HP-UX
1833611 Members
3307 Online
110062 Solutions
New Discussion

Problem with attach in mailx/sendmail

 
R.O.
Esteemed Contributor

Problem with attach in mailx/sendmail

Hi,

I triyng to send a mail from HPUX 11.0 as follows:

- Must have subject and body
- Must have a file attached

I tried:

uencode /tmp/file1.txt file1.txt | mailx -m -s "TEST" adress1@xxx.com

and

uencode /tmp/file1.txt file1.txt | sendmail -v adress1@xxx.com

But, I do not know how to put the body and, in the other side, the attached file (in this case is a text file) arrives in a bad format.
Does anybody know how to put the body and how to "format" the text in the attachment to be readable as in the source?

Thxs in advance and regards,

R.O.
"When you look into an abyss, the abyss also looks into you"
4 REPLIES 4
Stefan Farrelly
Honored Contributor

Re: Problem with attach in mailx/sendmail

You do it like this;

echo "Subject: " >/tmp/tempfile.$$
echo "" >>/tmp/tempfile.$$
uuencode >>/tmp/tempfile.$$

Then cat it into sendmail;

cat /tmp/tempfile.$$ | sendmail

Some mail programs may not like using sendmail as it formats differently to mailx, if you have a problem replace sendmail with maix in the cat command above.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Chris Wilshaw
Honored Contributor

Re: Problem with attach in mailx/sendmail

In order to make a unix doc readable via a Windows mail system, you use the ux2dos command.

Using sendmail:

(echo "test text\n";cat /etc/passwd | ux2dos | uuencode passwd.txt;echo "\ntest text2") | sendmail address

This sends a mail with the following as the body;

test text

** as attached file **

test.text2

The \n's are just to insert new lines to make the mail more readable.

the brackets () combine the echo's and cat command into a single output which is passed to sendmail

Virgil Chereches_2
Frequent Advisor

Re: Problem with attach in mailx/sendmail

You may also use metasend from http://hpux.cs.utah.edu/hppd/hpux/Networking/Mail/mm-2.7/.
With metasend you have also the possibility to attach multiple files at the same time.
It will handle all email headers according with the MIME type you specify on the command line.
Best regards,
Virgil
Steven E. Protter
Exalted Contributor

Re: Problem with attach in mailx/sendmail

Try the script i'm attaching.

Its production, you can take pieces of it.

If it fails, have your smtp relay server checked.

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