Showing results for 
Search instead for 
Did you mean: 

Sendmail; Insert file to an item

Markku Muhonen_3
Occasional Visitor

Sendmail; Insert file to an item


I try to send mail from HP-UX B.10.20 9000/811 to users own mail system (MS
Outlook). That rules OK, but
the question is, how can I insert file to an item ?

The command what I use is :

/usr/sbin/sendmail -t
where the itemname is a file which's like:

Subject:Headers of the message

message body

Thanks for the assistance.


Markku Muhonen
Terja Lange_1
Frequent Advisor

Re: Sendmail; Insert file to an item

I am assuming you wish to do this automatically thru a script. Use mailx


mailx -s "{your subject title}" "{to targets}" < myfile

This will make the contents of myfile the actual contents of the message.
hope it helps


PS. Terveisia suomalaiselta toiselta puolelta maapalloa.
Markku Muhonen_3
Occasional Visitor

Re: Sendmail; Insert file to an item

Hey Terja,

thanks for Your help.

But my final purpose is send a mail where I tell to a receiver that "Here is
Your binary file to print".
And that binary file must be same as it was when I send it from HP-UX.

PS. Terveiset kevaisesta Suomesta.
Berlene Herren_1
Super Advisor

Re: Sendmail; Insert file to an item

Markku, you can send attachments from the command line with sendmail by using
the following syntax.

#uuencode /etc/hosts hosts.txt | sendmail -v

Alan Riggs_1
Regular Advisor

Re: Sendmail; Insert file to an item

Berlene is correct, but that will send teh file attachment without a message
text. If I understand your question, you presently have a file "item" that
contains the subject header, message text, etc. You wish to also attach a file
"binary". To do so, try:

sendmail recipient@maildomain << EOM
`cat item`
`uuencode binary [file name for attachment]`

The above contains backtiks (accent grave) NOT single quotes.
Markku Muhonen_3
Occasional Visitor

Re: Sendmail; Insert file to an item

Hey Berlene and Alan,

thanks for Your good advises. You're gurus!

Alan is right, I need to do that kind of script and call it from my program.

Best regards

Gabriel Hermida
Occasional Advisor

Re: Sendmail; Insert file to an item

I?ve read the responses for this message on June 2/2000. I?ve been working with uuencode and mailx and I?ve used it with mailx to insert a file to a mail item with the next commands:

$uuencode file.txt file.txt >> item
$cat item | mailx -s 'subject' recipient@maildomain

where item contains the message text.

It works fine with our mail system, SoftArc First Class, but with other mail like and others, the file attached appears at the bottom of the text message in MIME format, not like and attach file.

I have to send mail to many mail clients and I want to know if there is a method to attach files that can be read by the major number of them.

Thanks for your responses.



Rita C Workman
Honored Contributor

Re: Sendmail; Insert file to an item

Well if you want to just send a file as part of the message, than any of the other responses will work just fine.
BUT...if your trying to attach a file and send the file via sendmail as an attachment than you can do this also.
First make sure you at least have Elm 2.4 on your box, and my example is for
a HPUX 10.2 (you need MIME capability) so be sure you have patch PHNE_15835 (it doesn't cause a reboot to load). To give you an example I ftp'd an excel spreadsheet to my box called test.xls Then I did the following:
First create a dummy file with the following line (just as you see it here)
[include test.xls application/msexcel base64]
Second from the command line:
elm -s "This is a test" ============================================
What this did was email to the file test.xls (and it comes as attached excel file) with a subject line of This is a test. It works.
You can do it with text files; image.jpg or gif files; and more. Might want to do some
lookups on IT Resource for more info.
It's a very handy tool that programmers can add right into the job streams and email reports to users instead of printing them....makes for paperless environment.