Operating System - HP-UX
1752794 Members
6355 Online
108789 Solutions
New Discussion юеВ

Re: sendmail with attachment script not working

 
SOLVED
Go to solution
Tonya Underwood
Regular Advisor

sendmail with attachment script not working

for x in $*
do

uuencode $x.info whatever | sendmail -fsomeuser@domain.com -t < /DR/headerfile

done

This is emailing just fine... only the attachment is not being attached... What is the problem?

Thanks!
Tonya Underwood
9 REPLIES 9
Mark Greene_1
Honored Contributor

Re: sendmail with attachment script not working

Instead of piping to sendmail, pipe to mail or mailx which will handle the attachment correctly.


mark
the future will be a lot like now, only later
Geoff Wild
Honored Contributor

Re: sendmail with attachment script not working

I'd use mailx as well...

But, this should work:

uuencode | sendmail someuser@domain.com

This thread may give you some ideas:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=183409

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Tonya Underwood
Regular Advisor

Re: sendmail with attachment script not working

I must force it to send with the sender as someuser@domain.com and I am not aware of there being an equivalent -f option in mailx...
John Kittel
Trusted Contributor
Solution

Re: sendmail with attachment script not working

I have accomplshed this task ( script to send uuencoded attachments via sendmail )... but I don't know if there is a simpler or better method than mine. Reading the previous responses to your question leads me to believe that it should possible to do it more easily than I have done, but here is my method; you can use it if you wish and/or if you get no better ideas. I have stripped out extraneous niceties such as handling multiple input files of various formats, input validation, etc. This is (almost) bare minimum. I am constructing the mail and mime headers in my script and including them in my pipe to sendmail. The boundary text is somewhat arbitrary, but not completely. If you try to use this, and if you don't understand how the boundaries are constructed, I suggest you leave them alone ( they way I have them), until you get it working, then modify if you desire.

Here you go...

#!/usr/bin/sh
From="me@myplace.com"
To="whomever@wherever.com"
Subject="uuencode attach test"
(
cat <
John Kittel
Trusted Contributor

Re: sendmail with attachment script not working

BTW, when you call my script supply one argument, the name of a uuencodeable file, such as a gif file.

- John
Michael Tully
Honored Contributor

Re: sendmail with attachment script not working

I always use this example:

for e in `echo file1 file2 file3`
do
uuencode $e $e.txt
done | mailx -m -s "mymail" username@domain.com
Anyone for a Mutiny ?
John Kittel
Trusted Contributor

Re: sendmail with attachment script not working

OK, even simpler, and improved version of my script, which also does the "sendmail -f" which you require:

#!/usr/bin/sh
From="john.kittel@kaisertwd.com"
To="john.kittel@doctor.kaisertwd.com"
Subject="uuencode attach test"
(
echo "Subject: $Subject"
echo "Mime-Version: 1.0"
echo "Content-Type: multipart/mixed; boundary=\"KACC.boundary.09112002\""
Base=`basename $1`
echo "--KACC.boundary.09112002"
echo "Content-Disposition: attachment; filename=\"$Base\""
echo "Content-Type: image; name=\"$Base\"; charset=US-ASCII"
echo "Content-Transfer-Encoding: uuencode"
echo ""
uuencode $1 $1.en
) | /usr/lib/sendmail -f$From $To
exit 0

- John
Steven E. Protter
Exalted Contributor

Re: sendmail with attachment script not working

The best I can do is provide a script that works.

My production version. Does a bit more than you like.

Two possibilities here:

1) Compare my methodology to your own and correct your script.
2) Modify mine to meet your needs.

Note that certain symmantec gateways need to be patched to correctly process these type of scripts. Translation: It may be your smtp gateway and not your script.

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
Tonya Underwood
Regular Advisor

Re: sendmail with attachment script not working

Thank you all so much... it's working now :)