Operating System - HP-UX
1820475 Members
2847 Online
109624 Solutions
New Discussion юеВ

Send Mail Mesage from UNIX with multiple "Attachments"

 
SOLVED
Go to solution
Alzhy
Honored Contributor

Send Mail Mesage from UNIX with multiple "Attachments"

Can't seem to get the Syntax Right for a mail message + multiple attachments.

I have for one file, no mail text:

"uuencode /var/adm/somelog log.txt|mailx -s user@add.com"

But the mail client, received the uuencoded attachment data instead of the attachment itself (mail client settings or sendmail settings?).

So 2 Questions:

1. How to send e-mail with message text and multiple attachments
2. How to fix the problem wherein the mail cient (Outlook so far tested) does not interpret the attachment but displays the uuencoded file.


Hakuna Matata.
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: Send Mail Mesage from UNIX with multiple "Attachments"

My weapon of choice for this is elm -- using the command-line interface rather than the GUI. Multiple attachments with email text between them works quite well.

Elm will work just fine from the command line and it's quite easy. I have scripts that use it that are run everyday.

Within the body of your email add this:

------------------------------------

This is my text. How are you?


[include /tmp/myattach application/octet-stream base64]

This is some more text in the middle.
I hope you are feeling well.

[include /tmp/myexcel.xls application/ms-excel base64]

This is a closing message in the email.

----------------------------------------



That will attach /tmp/myattach and /tmp/myexcel.xls. You can include multiple attachments using this method. If you are running 10.20 make sure that you have a MIME enabled version of elm (PHNE_15835 or later).

Then to use it from a script:
elm -s "My Subject" user@mailserver.com < myletter

Where myletter contains the attachment include statement as well as your message text. It is also necessary that you have a .elm directory
under the senders home directory because unlike the interactive version of elm the command-line version will not create a .elm directory automatically.

Regards, Clay
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: Send Mail Mesage from UNIX with multiple "Attachments"

Hi,

I would use something like this

rm -f attach
for file in file1 file2 file3
do
uuencode $file ${file} >> attach
done

mailx -s "multiple attaches" user@add.com < attach

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Dave La Mar
Honored Contributor
Solution

Re: Send Mail Mesage from UNIX with multiple "Attachments"

Nelson -
Our shop uses the mailx process. Find attached different mailx scenarios including multiple attachments.

Best regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: Send Mail Mesage from UNIX with multiple "Attachments"

Sorry Nelson, it did not show the multiple attachments. See below example with body:

mailx -m -s "Hello" dlamar@gottschalks.com << END
`ux2dos /home/dlamar/.kshrc | uuencode /home/dlamar/.kshrc.txt`
`ux2dos /home/dlamar/.profile | uuencode /home/dlamar/.profile.txt`
This is all you get.
END

Again, best regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Steven E. Protter
Exalted Contributor

Re: Send Mail Mesage from UNIX with multiple "Attachments"

The script I am attaching does one attachement.

The modification to get it to do multiples is trivial, though you will have to modify the input parameters and adjust the subject word collector to accommodate multiple attachment directives.

Simply put, you tell this script who the mail is from who it is to and what the attachment name an subject is and you're done,it gets the attachment out the door.

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
Alzhy
Honored Contributor

Re: Send Mail Mesage from UNIX with multiple "Attachments"

A. Clay, unfortunately, elm is outlawed in our enterprise. So mailx is what we will use for all dialects. I though about multiple uuencodes streamed to a temp file but kudos to Dave La Mar for the TOHERE approach and the back-tciked inserts!

Hakuna Matata.