FormMail.pl - HTML form - fails

  memy 22:36 20 Feb 2004
Locked

Could somebody please take a look at the HTML for the form> tag on click here and confirm it is coded OK. The form submit fails with an 'Internal Server Error'. The FormMail.pl script is definitely present within cgi-bin and CHMOD = 755.

If this looks OK, I would like to follow this up with a check on the parameter coding within the FormMail.pl script itself. But first things first!

The current syntax of the Form> tag has evolved from that generated automatically by Dreamweaver MX which gave persistent HTTP 405 errors - so things have moved on a little!

p.s. if you decide to try the form there are numerous mandatory fields, so just insert any old rubbish to complete it!

Many thanks, M

  Taran 09:05 21 Feb 2004

The address to the formmail script should be cgi-bin/formmail.pl and not the full URL of the site

The form should have the following fields:

<form name="form1" method="post" action="/cgi-bin/FormMail.pl">
<p>
<input type="hidden" name="subject" value="Title of the email subject" />
<input type="hidden" name="redirect" value="Full URL including http of the 'thank you for contacting us' page" />
<input type="hidden" name="recipient" value="email address of the recipient" />

You can specifiy most of this in the script if you know how, but the above is probably the simplest method for getting it to work.

The Formmail script itself should have this for its first line [sometimes differs from one host to another]:

#!/usr/bin/perl

The next unxommented line is the address of your email program script on the server:

$mailprog = '/usr/sbin/sendmail -oi -t';

@referers = ('your site URL without www','your site URL with www','you can use localhost as well if required');

@recipients = &fill_recipients('your site URL without the www','again you can leave localhost in if required');


And that should get you running.

You can alter and configure lots more but normally you don't need to and the above will take pretty much any form field type you could mention and process it correctly when passed through the Formmail.pl script.

One last thing: you may want to rename FormMail.pl to something else like contact.pl or whatever, then change the reference in the form to point to that file in your cgi-bin.

FormMail.pl is often targetted by spammers and renaming the file will help to prevent this from happening on your web server.

;o)

Hope that helps.

  Taran 09:07 21 Feb 2004

The above should have read:

The form should have the following fields:

<form name="form1" method="post" action="/cgi-bin/FormMail.pl">


<input type="hidden" name="subject" value="Title of the email subject" />

<input type="hidden" name="redirect" value="Full URL including http of the 'thank you for contacting us' page" />

<input type="hidden" name="recipient" value="email address of the recipient" />

I forgot to put hard returns in to space the lines out for you.

  memy 15:31 21 Feb 2004

Will try again. M

  memy 16:24 21 Feb 2004

I'm now testing on a different server and still get "Server Error: the server has detected an internal error".

The HTML is now here click here and the FormMail.pl variables are set as follows:
#!/usr/bin/perl
$mailprog = '/usr/sbin/sendmail -oi -t';
@referers = (‘youngcc.co.uk’,’click here’);
@recipients = &fill_recipients(‘youngcc.co.uk’);

I have checked that the path to perl and sendmail are correct.

Any other ideas? Thanks, M

  memy 16:26 21 Feb 2004

Sorry ... the @referers and @recipients have come out strangely above but are as per your instructions. Should the my IP Address (i,e for youngcc.co.uk) also be in the para (is that the localhost?) - if so how do I find out what it is? Ta, M

  Taran 16:50 21 Feb 2004

No, you don't need to list your IP address as well. It works as well purely off domain names with and without the www prefix, as I listed them in my earlier post.

Does your server error list an error number at all ?

Your recipients line has no single quotes to wrap your domain address and neither does your list of referers.

You listed this:

@referers = (?youngcc.co.uk?,?same address with the www?);

@recipients = &fill_recipients(?youngcc.co.uk?);

Change them to this:

@referers = (?'youngcc.co.uk'?,?'?same address with the www'?);

@recipients = &fill_recipients(?'youngcc.co.uk'?);

Those single quotes are crucial in Perl coding.

You will possibly find that your other configuration lines in the formmail script are similarly wrong. It's a common error and unless you know code to begin with you never notice it until things go off on one.

;o)

  Taran 16:54 21 Feb 2004

I was using a different web browser and my single quotes got mangled.

Looking at your post above in IE, your single quotes were chewed up too, so my last reply may not be appropriate.

  memy 21:05 21 Feb 2004

This is the full error message.

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. ----------------------

Apache/1.3.29 Server at click here Port 80

  memy 21:09 21 Feb 2004

Yes, I placed single quotes, BUT ... a thought ...

when I opened the original .txt file to configure it the lines were all merged into one, so I opened it in Word to get it to format; i.e. place each line on a new line. When I saved it back I had to make a choice of format and selected Windows Default. In case this threw a spanner in the works, I'll start from scratch with a simple text editor (Notepad) and try again. Watch this space! M

  memy 21:37 21 Feb 2004

I tried configuring the script with Wordpad - same result. Then I used Notepad and it is now working. I think it Word/Wordpad must have been saving the file in the wrong format. Notepad saved it as ANSI.

Anyway, thanks very much for all your help and maybe we both learned something.

Regards, Morag

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

50 best online Adobe XD tutorials

iPad Pro 10.5in (2017) review

Comment connecter un MacBook à une TV ?