Operating System - HP-UX
1752618 Members
4327 Online
108788 Solutions
New Discussion юеВ

Re: send email with attachment in command line

 
walter lee_1
New Member

send email with attachment in command line

Please help.

I need to find out how to send attachment in HP-UX command line? I have successfully send attachment using ELM interactive mode.
7 REPLIES 7
Denver Osborn
Honored Contributor

Re: send email with attachment in command line

# elm -s "subject" user@host < attach.file

This will work on an ASCII file, if the attachment is binary I think you will have to UUENCODE it.

Hope this helps!
Dale McNamara
Frequent Advisor

Re: send email with attachment in command line

another option for you would be to use:

#uuencode your_file_name | sendmail -v user@mail

There has been alot of interest in this area, for some other ideas, use the search button and search for "attachment"
Mike Gordon
Occasional Advisor

Re: send email with attachment in command line

I've used an additional utility called mpack that converts messages to a MIME format. This ensures that it can be read ok by any MIME compatible mail client.

MPACK is available from the HP-UX Software portal.

Uuencode doesn't work very well with the Groupwise mail client.
Rita C Workman
Honored Contributor

Re: send email with attachment in command line

I've seen similar requests for this on other messages...and I have sent this before. So I'm sending it again to you...Yes- you can send a file as a TRUE file attachment and actually preserve what the file is...here is the info:
First make sure you at least have Elm 2.4 on your box, and my example is for a HPUX 10.20 (you need MIME capability) so be sure you have patch PHNE_15835 (it doesn't cause a reboot to load).
The next thing you have to do is create a small file (ex include.file) that is used to send the file as an attachment. There are a few things you could read on this for more details at HP's IT Resource if you want. But simple create a file with this syntax:
[include text.txt text/plain base64]

where text.txt is your file.

The general format is: [include filename type/subtype encoding]
type/subtype= text/plain, image/gif, image/jgp etc..
encoding=base64, quoted-printable etc...
Another example might be for a Word doc:
[include file.doc application/msword base64]

Now from the command line to send this file as an attachment to user_abc:

elms -s 'Test attachment file' user_abc@your_org.com ============================================

What this did was email to user_abc@your_org.com the file test.txt with a subject line of Test attachment file. If you sent a Word doc it would come across and be a Word file attachment. It works.
You can do it with text files; image.jpg or gif files; and more. Just change the include stmt like.....And you can use this and build it right into job streams, so you can then email reports and files when batch jobs are done....It's a real paper saver.
If you want to do some lookups on IT Resource for more info.

Regards,
Rohak
Advisor

Re: send email with attachment in command line

no it will not work. i think u cannot understand my question.
when i send a mail from unix box to microsoft outlook. when i receive in microsoft outlook
its not attachment.
suppose if i want to send some attachment from microsoft outlook. there is one option for attachment. like resume.doc and some pdf file like that.
Anthony deRito
Respected Contributor

Re: send email with attachment in command line

Walter, the question you posted seems simple enough. In support of Dale's response, the command he gave you does work. Except the command should be:

# uuencode file_name file_name | sendmail -v nnn.nnnn@eee.com

Specify the filename twice as shown as per man page.

The other solutions will work as well. Have you tried the suggestions?

Tony

Rita C Workman
Honored Contributor

Re: send email with attachment in command line

Walter,

The Include statement works for doing this.
I have even zipped files, they were just ascii files on the UNIX box and sent them using the Include coded as if they were Word docs...they came across as attached files and when you clicked on it, MS automatically unzipped it...and voila...
I can send a file from the UNIX command line and it will appear as a Word or Excel attached file....what's your email??? maybe we could try sending you an excel file and let's see how it comes to you...

regards,
rcw