Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help re-using formmailer.pl script

Status
Not open for further replies.

wr213

IS-IT--Management
Apr 2, 2002
24
US
Hi,

I am a newbie so my question might seem a little basic to most of you. I have a site that uses multiple forms. Each forms is for a different request however they all come to me for distribution which I do manually. What I am looking for is a way to modify the script so that on some forms it gets send to a different set of email addresses besides me. I tried renaming the formmail.pl file formmailerinh.pl for inh info etc. It didn't work. So I modified the original file and saved it under the same name inside another folder and did the same at the cgi-bin folder level. so the command line would be cgi-bin/foldername/formmailer.pl and it gives me the 500 internal error line. I set the chmod to 755, tranferred the files in ascii and all that. What do I need to change inside the script besides the referrers or email addresses that will allow me to send each form to different users?

I can forward the file to whoever needs to see it.

Thanks in advance.
 
The standard formmail.pl uses a recipient variable which should be the intended target of the form,

its a hidden variable in the <form> section;

so in theory all you have to do is modify the HTML forms so that the recipients reflect the intended addressee

HTH
--Paul

BTW older versions of Formmail.pl are a spammers dream, so look at the version you've got, and check if you need to upgrade

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Paul,

That is what I thought and that is the reason I renamed the files and adjusted the line of code on the form itself from
<form action=&quot;/cgi-bin/formmailer.pl&quot; method=&quot;POST&quot;>
TO
<form action=&quot;/cgi-bin/formmailernewname.pl&quot; method=&quot;POST&quot;>

Inside the cgi-bin folder I have the file formmailer.pl and formmailernewname.pl but it didn't work citing internal error code 500. As I said, everything is chmoded 755 and uploaded in ascii. All I did inside the renamed form was add the email address of the people I want THAT particular form to go to.

As for the date of the form, this is the spam proof version.

this is the actual html:
<input type=&quot;hidden&quot; value=&quot;1&quot; name=&quot;start&quot;>
<input type=hidden name=&quot;redirect&quot; value=&quot;<input type=hidden name=&quot;recipient&quot; value=&quot;1&quot;>
<input type=hidden name=&quot;subject&quot; value=&quot;Money Quote Request&quot;>

I am thinking that it has to be some code internal in the script that needs to tells the routine that is ok to do what the form asks to do. I am reaching for straws I guess.

Thanks for your help.
 
Inside the script, and I'm guessing here, there's some sort of branching mechanism to equate &quot;1&quot; with the e-mail address intended, so what you need to do is find some way to equate &quot;2&quot; with someone else's e-mail address.

The 500 internal server error has a more descriptive reason in the logs (on apache/linux usually /var/log/http/error_log).

Post the script, and we'll have a look at it

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Paul,

here is the error log I found in regards to the script:
[2003-07-16 14:51:14]: error: file has no execute permission: (/home/wernerr/public_html/cgi-bin/formmailerinh.pl)
[2003-07-16 00:49:11]: error: file has no execute permission: (/home/wernerr/public_html/cgi-bin/formmailer.pl)
[2003-07-15 17:54:32]: error: file has no execute permission: (/home/wernerr/public_html/cgi-bin/formmailer.pl)

I have several email addresses in the script previously so what I did was replace some with new ones and rename the script.
 
There's a problem with the permissions, check the ownerships of the file as the permissions.

As regards the email addresses is that getting you out of jail

--Paul
 
LOL...that makes sense Paul, but I don't know what I am looking at...permissions? isn't that what chmod to 755 is? Should I make them 775? or 777? I am not a programmer just a dabbler so I don't know what it really means. The original file works fine at 755 though. Not only that though the file has become all unwrapped in the text and is hard to read.

What do you mean by getting me out of jail? Not sure what you mean.

I would post the whole script here but is HUGE!.

Thanks
 
What webserver are you using?


Getting out of jail, a term from the game of Monopoly(R), mean9ing get out of trouble (Do not pass go, do not collect €300...) - No offence intended

--Paul
 
A linux/unix server with apache and the normal cpanel 6.0.

As for the email comment, I guess I am just trying to get by using the same script and only changing the name of it. In theory it would seem to work, but is not so far. I have 5 emails inside the script, not sure if that would be a problem. Before I used it with 3 email addresses and worked/works fine.
 
Werner,
In theory you don't need to change the script. You should be able to use the same script (the one that works), and just add a branching mechanism to select a different e-mail address, depending on the value that is passed in the recipient variable

1 - goes to you
2 - goes to someone else
3 - goes to someone else

Then you just change the form attributes in the HTML

Can you post the block of code where the recipient is changed to your address

--Paul
 
Here is the code:

BEGIN
{
$DEBUGGING = 1;
$emulate_matts_code= 0;
$secure = 1;
$allow_empty_ref = 1;
$max_recipients = 5;
$mailprog = '/usr/lib/sendmail -oi -t';
@referers = qw( @allow_mail_to = qw(info@ffcorp.com notes@nationfunder.com wrr@aol.com ca134@fcol.com localhost);
@recipients = ();
%recipient_alias = (
'1'=>'ca134@fcol.com,notes@nationfunder.com, wrr@aol.com,info@ffcorp.com',
);
@valid_ENV = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
$locale = '';
$date_fmt = '%A, %B %d, %Y at %H:%M:%S';
$style = '/css/nms.css';
$send_confirmation_mail = 0;
$confirmation_text = <<'END_OF_CONFIRMATION';
From: you@your.com
-------------------------------------------------------END

And all I wanted was to add one more email address on the
&quot;recipients&quot; blocks. That was the only place I made the additions. Did I have to make additions to both places or lines of code? Another words, &quot;allow mail to&quot; block as well?
 
Hi.

Excuse me for butting in, but did you create your new file on a Windows or DOS computer? If so, it won't run on a Unix Box without some modifications.

When you upload your file, it needs to be in Unix Format. If you can telnet to the Unix Box, you may be able to run a program called Dos2Unix (if it exists on the Unix Box). e.g. &quot;Dos2Unix myfile.pl&quot;. Ask the ISP who is hosting your scripts (or check their helpfiles).

Otherwise, you will need to use a Windows program that writes in Unix-friendly format (not Notepad or Word, etc).

I use OprtiPerl 4, and have to save files in DOS format when I run them on my Win2000 server, and then re-save them in Unix format when I upload to my Unix Box. If I don't, I get error 500 (mainly).

Hope this helps.

Terry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top