System Administration

Re: email script help needed

 
SOLVED
Go to solution
Shar Hunter
Frequent Advisor

email script help needed

I have a Progress driven application running on HPUX 11.

The application has the ability to send data to what it calls a printer. But all it really does is call a unix print command. I found that I can insert any unix command and it will run. So I started messing with scripts to achieve various goals.

The latest one is to take the standard output, write it to a file, then afterwards send the file as an attachment in an email.

I managed to get it to work, but not quite right. Now it is over my head. The problem is that the script sends out the email to 2 recipients. One is the one I intend the other is a default email address based on the user who invokes the script. I do not want to email going to anywhere other then the single email address that I define inside the script. The other problem is that the 'from' address is incorrect. I want to be able to define the 'from' address, so the receiver of the email can respond.

The email is generated in unix, sending output generated in a Progress application. But the reply address should not be back to the unix box, but instead a definable email address of a specific user.

I am including the script for you all to look at, and give any suggestions.

Thanks.

I hope this is clear as mud. ..
I don't think I'm in Kansas anymore.
4 REPLIES 4
Marco Paganini
Respected Contributor
Solution

Re: email script help needed

Hello Troy.

One way is to use sendmail directly. Here's how: Suppose you want to send a file named "TEST" to troy@domain.com and troy@foo.com as if coming from mysteryuser@foo.com. You can do something like that:

temp=/tmp/mail.$$

echo "From: mysteryuser@foo.com" >>$temp
echo "To: troy@domain.com, troy@foo.com" >>$temp
echo "Subject: This is the subject" >>$temp
echo "" >>$temp
cat $temp TEST | /usr/sbin/sendmail -t
rm -f $temp

You can even do it without intermediate files. All you need are your standard RFC822 headers (From, To, Subject) and a blank line before the mail itself. Sendmail will do the rest for you. Also note that this will only work if the sending user is a 'trusted' user (see /etc/sendmail.cf).

Hope it helps,
Paga
Keeping alive, until I die.
Shar Hunter
Frequent Advisor

Re: email script help needed

Thanks a lot!

This is a perfect example of why I always look for help here! It is fast and efficient.

The suggestion worked perfectly. We just added email ability to our old clunky application - no need for the expensive upgrade now!

ha ha.

Thanks. This solution is exactly what I needed.
I don't think I'm in Kansas anymore.
Joe Gilligan
New Member

Re: email script help needed

Troy, I was looking through, and noticed your issue was very similar to one I'm facing. If you don't mind my asking what progress DB product are you using?

Thanks,

Joe Gilligan
Hey, what's this do?
Shar Hunter
Frequent Advisor

Re: email script help needed

Sure no prob.

We are using Trend, which is now called Nxtrend.

It is a wholesale warehousing application designed to handle inventory and sales.

Troy
I don't think I'm in Kansas anymore.