Operating System - HP-UX
1833832 Members
2168 Online
110063 Solutions
New Discussion

Attaching files to email messages

 
SOLVED
Go to solution
Guilherme Belinelo
Occasional Advisor

Attaching files to email messages

Hi,

I?ve found out how to attach text files to an email. It?s just put a header on it and use sendmail with -t option. I?m using:

cat header attachment.txt | sendmail -t

Where header contents is:

DSV$ more header
To: email@domain.com
Content-Type: multipart/mixed;
boundary="----_NextPart_000_01C0DFDE.6EF1A3BC"

It works fine for text or ascii file but I need to write a script which accepts any kind of attachment (.exe, .pdf, etc...)

I tested it for a .pdf file and the file arrived as attached but it was corrupted and couldn?t be open.

The problem is the cat command, which open the pdf file. What I need to do is use some command or anything to put the header lines before the file that I want to attach.





4 REPLIES 4
Rita C Workman
Honored Contributor

Re: Attaching files to email messages

You might try this thread and see if it will help you, it offers three ways to send attached files...

http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x41950559ff7cd4118fef0090279cd0f9!0,00.html

Just a thought,
/rcw
Pedro Sousa
Honored Contributor

Re: Attaching files to email messages

Hi!
you can also use:
mailx -s "Subject" <
for example:
mailx -s "PROBLEM" ric@iii.com < /tmp/sss.exe
good luck.
Alan Riggs
Honored Contributor
Solution

Re: Attaching files to email messages

It has been answered before, but I personally use uuencode.

uuencode file_name attachment_name | mailx -s subject target@abc.com
A. Clay Stephenson
Acclaimed Contributor

Re: Attaching files to email messages

Hi:

My favorite way to do it is with elm include statements:

e.g.
To: Yogi

Text stuff
More Text
[include myfile.dat application/octet-stream base 64]

More text 2.
[include myfile2.dat application/octet-stream base 64]

Let's say that the above was in a text file called F2.

elm -s "Transfer Files Subject" booboo@mother.com < F2.

The nice feature here is that multiple attachments are easy. Take care that your include statements have no leading white space and are contained on 1 line.

If you are running 10.20 you will need to patch elm (PHNE_15835).

Regards, Clay
If it ain't broke, I can fix that.