PDA

View Full Version : Form Mail config error



walt
02-13-2005, 04:10 AM
I'm a new user with problems setting up Form Mail.

I get an "Internal Server Error or misconfiguration", identical to the one described in the thread at

http://forums.westhost.com/phpBB2/viewtopic.php?t=1669

I have studied all the FormMail-related posts on this forum (especially the one above) with no good results.

Some added info:

(1) I already had a catch-all email account (as noted in that thread). I removed and re-installed the catch-all; nothing changed.

(2) I have the reseller package, with quite a few domains installed. The problem surfaced in "www.onelowdomain.com". I copied the form to "www.mytopdomain.com" and got the same error. This does not rule out a multiple-domain problem, but neither does it confirm it.

(3) I modified FormMail.pl to add "onelowdomain" to the Referers array; made no other changes. (I don't know Perl; I assume that file doesn't need to be compiled?????)

(4) The "recipient" field in my form is a valid email User account, not an alias, and is formatted as "username@mytopdomain.com".

(5) I wonder if the problem may still be related to the catch-all configuration. My catch-all account is called "mytopdomain@mytopdomain.com". That has worked for the past month to gather up all my email from the various domains, but maybe it's not right for FormMail.

(6) I also wonder if I have been blinded by that post, and am looking in the wrong place!!!

I've spent several hours trying to test this out for myself. I have a few ideas for other tests (all too lengthy to do before I sleep), with a fresh start tomorrow. In the meantime, I'll throw myself on the mercy of you experts. Any ideas? Thanks for the help!
________
RM85 (http://www.cyclechaos.com/wiki/Suzuki_RM85)

jalal
02-13-2005, 07:07 AM
The error usually means there was an error running the script. Probably nothing to do with domains or email accounts.

Likely problems are:
1. The script has been saved in Windows format
2. It has been uploaded 'badly' (line endings converted).
3. The path to perl is wrong in the first line of the script.
[ed]4. You have added some invalid perl code into the file.

One way to check is to shell into your account and then run the scipt manually. That will give a you a clearer error and help you find the problem.

sunzon
02-13-2005, 04:21 PM
Often in a perl script an email address needs an escape before @ ("mytopdomain\@mytopdomain.com"). I don't know Formmail.
Second comment, just to make sure you haven't inadvertantly made a syntax error, have you tried it without your single change (add "onelowdomain" to the Referers array) just to see if it works that way.
btw no need to compile.

walt
02-13-2005, 04:23 PM
Thanks a lot for your suggestions, jalal. The comments about line endings and invalid perl code appear to be in the right neighborhood.

I have isolated the problem, but don't know how to fix it.

The root of the problem is, in fact, multiple domains, but there is another issue. I re-installed FormMail and copied my form to "mytopdomain.com" where it runs perfectly, catching required fields, etc. But in order to run the form at "onelowdomain.com" I <<must>> add the lower domain to the @referer array (a config variable) in FormMail.pl ("must", at least, according to Matt's documentation and my tests so far).

And there is the rub: When I try to edit FormMail.pl, I corrupt the file, producing the Internal Server error. I have tried the following:
(1) edit FormMail.pl directly using the Site Manager edit feature;
(2) copy/paste the file (using SM edit feature) to Notepad, then FTP'ing the file back, changing to 755, etc.
(3) MERELY opening the file using SM edit feature, touching NO KEYS, and then saving the file <<unchanged>> (but, obviously, not really unchanged!)

All of those actions corrupt the file. The form works perfectly before the attempts to change FormMail.pl (after reverting to the original file), and generates the Internal Server error after each attempt.

So my question now is simply: How do I edit FormMail.pl? Any suggestions for the proper tool? And if that tool is on my computer, how do I download a clean copy of FormMail.pl to that editing tool? Is there another editing script on WH?

walt
02-13-2005, 04:27 PM
Thanks, sunzon. We were both apparently writing at the same time; mine took longer.

Your diagnosis was correct; I had in fact corrupted the .pl file while making the @referer change (explained in my previous post).

sunzon
02-14-2005, 07:58 AM
If you are corrupting the file with your changes, either you are making syntax errors, or making an impossible config.
I took a quick look at:
http://www.scriptarchive.com/download.cgi?s=formmail&c=txt&f=README

As I interpret what you seek to do, you need to set:

@referers = ('mytopdomain.com','onelowdomain.com');

and

@recipients = &fill_recipients('mytopdomain.com','onelowdomain.c om');


but the proof will be in the eating :-)

walt
02-14-2005, 11:34 PM
sunzon, the proof indeed is in the eating, and the pudding is sour!

After extensive tests, I have verified my diagnosis and am ready to put in a help ticket with WH. All the evidence points to a problem with Site Manager.

(Before explaining my diagnosis, let me comment on sunzon's last post. What I tried to do originally was to make the exact change sunzon suggests to the @referers array, but that corrupted the file. BTW, I don't believe I need to change @recipients, as long as the recipient is on-site; I anticipate needing to change that later. In any case, that's not the problem.)

The key to analyzing this problem is in recognizing that I can (and have) replicated the symptoms repeatedly by simply opening and saving the FormMail.pl file WITHOUT MAKING ANY CHANGES -- literally, never touching the keyboard. Whatever is happening is completely hidden to me.

Every time I tried to change FormMail.pl, I corrupted the file. That led me to the following possible conclusions:
(1) I'm crazy
(2) I have a problem with my computer (spyware???) perhaps interfering with a simple edit. (I run Ad-Aware and Spybot S&D, so that's not likely.)
(3) I have a problem with the particular copy of Site Manager installed on my domain.
(4) There is a more generalized problem with Site Manager.

Earlier this evening, I re-installed FormMail on my domain. Then I performed the following steps:
(a) Ran the form from my computer; verified that it works perfectly, including blank-field checking and redirecting to a specified page after completing the form.
(b) From a computer 800 miles away (thereby eliminating my ISP and local switches as part of the problem) I had my son open and save FormMail.pl on his computer.
(c) Tried to run the form again from my computer -- et voila! "Internal Server Error" !!!

I'm satisfied that eliminates possible conclusions (1) and (2) (Well, I may still be crazy, but for other reasons.) That leaves me with (3) and (4). I find it hard to believe that the problem is unique to my installation (3), as I don't know enough to change anything that would have affected Site Manager. That leaves me with (4), a generalized problem with Site Manager.

I will put in a help request with WH to see if they can track down the problem.

In the meantime, I'm curious: has anyone else seen this problem before? Can anyone else replicate this problem from your domain? I'm sure it would help WH if we could demonstrate whether others have the same experience.

To test, do the following:
(1) Pick a form that uses Form Mail. Verify that it runs correctly.
(2) Make a duplicate copy of /cgi-bin/formmail/FormMail.pl (You can't copy directly, so copy up or down one level, rename, and then move the file back.) An alternative is to be willing to re-install FormMail if you happen to corrupt your file.
(3) Simply open and then save FormMail.pl using Site Manager's editor.
(4) Run the form again to see if it works correctly, or produces an Internal Server error.
(5) If you get an error, revert to a good copy of FormMail.pl.

One other question comes to mind: If indeed there is a problem with the editor on FormMail.pl, does the same problem apply to other perl files? I'm sure it does NOT affect HTML files, as I have used the editor for those hundreds of times.

Thanks, everyone, for the help.

jalal
02-15-2005, 01:42 AM
Just by opening a file, you are changing it.
Sounds strange, but its possible that what is known as the 'atime' is changed, and maybe the permissions. Of course, Site Manager shouldn't be changing the permissions, but that is one possibility. Certainly if Site Manager was opening the file and closing it and turning off the executabel bit, then that would cause the problems you are experiencing.

If I have time later, I'll take a look at one of my sites and see what happens.

If you know how to log in to the shell (if not, forget it) then you can try this:
Login to your site
Run this command:
ls -al /var/www/cgi-bin/
Do what you do with the site manager, then run that command again and see if any of the flags for that file have changed.

Good luck

jalal
02-15-2005, 02:16 AM
Ho yey!

Can't believe no-one noticed this before. When you open a file to edit it in the FileManager and then save it (even when you make no changes) it saves the file in DOS format!

This isn't a problem for HTML files, but for a Perl script its a disaster. Definitely a bug so file a report for it.

For now, if you make changes to a script, then you will probably need to run something like:
dos2unix FormMail.pl
from the 'Execute a Shell Command' feature of the File Manager, this will change the format of the file back to Unix and it should work.

walt
02-15-2005, 04:42 AM
I'm beginning to remember why I hate programming!

First, thanks jalal for confirming the problem. It may be that no one found it before because they're using better techniques than I am, so they never thought of doing it my way. My technique is to develop and test one small part at a time, writing the code in WordPerfect and then copy/paste to the web site using SM's editor. Then I test it in IE to see if it works. (May be a lousy technique, but it matches the way I think. I keep all three windows open, and things usually move very quickly.) So....it was natural for me to try to edit the .pl file online.

I admitted in my first post that I don't know perl. I also don't know linux. I've done no real programming in 20 years, and I don't really want to now (I don't count HTML as programming). So I'm taking baby steps to get up to speed--like learning to use dos2unix!!!

That said, running dos2unix does not seem to be doing anything. My screen blinks, the taskbar shows "done", but nothing appears in the "Results:" area. Is this normal?

When I look at the directory, the date does not change; more importantly, the form will not run.

I have tried these variations in the shell command line (all from the /cgi-bin/formmail/ directory:

dos2unix FormMail.pl
dos2unix -n FormMail.pl FormMail.plnew
dos2unix /var/www/cgi-bin/formmail/FormMail.pl

BTW, the second variation does not create a new file -- or perhaps it puts it in Neverland.

I really hate to keep asking for help, but I would certainly be grateful if you could suggest something.

sunzon
02-15-2005, 06:03 AM
Well done Jalal!
who'd have thought of that!

OK Walt, let's get back to some basics to solve this corrupt file problem.

1> Don't use WordPerfect to edit the pl file. Use Notepad or any other pure text editor (or search the internet to find a free one). In any case you need to make sure you save the pl in unix format, or at least in dos format (=txt) (so that the command "dos2unix FormMail.pl" will work). I suspect you are currently saving it in a "doc" format with a pl ending. Maybe WordPerfect allows you to "save as" either unix or at least "txt" format. If you save it in "txt" format and get that wrong ending (FormMail.pl.txt) you can avoid this by putting quotes around your file name when you save it, this avoids adding a default extension, alternatively edit the name in windows. If you are unsure, you could even send the file to a friend who can resave it for you in the right format and send it back to you, just to be sure you have this angle under control.

2> Now we need to upload it properly, with Jalal's discovery, using the SM is not the way. It will have to be via FTP or telnet. FTP is the most natural way and I do recommend you use it/get one, but it seems you know how to handle telnet so use that. Btw after a "cd" to a new directory do a "dir" to see what files are there just to make sure you are in the right directory, it helps avoid inadvertant mistakes.
Again, you could even get someone else to ftp the file from their computer into your site so you are absolutely certain this angle is under control too.

3> Finally make sure you remember to set permissions for the new file (chmod 755).

HTH, let us know progress......

PS: though it costs something (they have a free trial), I recommend http://textpad.com as a texteditor, with its plugins you can color identify perl and html syntax and more, multiple edit etc, all in text format. Very practical ( particularly for people who hate programming :-) ).

walt
02-15-2005, 06:41 AM
Well done, both of you!!!!!!

I'm finished. Problem solved; everything works perfectly. I will append my help ticket to let the people at WH know what we have learned.

I was never using WordPerfect to edit the .pl file; I was trying to do that using Site Manager's edit facility. (I use WordPerfect routinely for HTML, and would not want to give up the formatting & documentation capabilities there.) Jalal correctly discovered that it was saving the file in DOS format. (Actually, now that I have seen a proper Perl format, it appears to me that SM's editor was converting the file to DOS format when it opened, not when it saved. I didn't recognize that, because I had never seen a Perl file!)

I realized that I didn't really need to know how to run dos2unix. All I really needed to do was figure out how to download the .pl file, which I also had never done. I found an FTP download program, edited the file in Notepad to change the @Referer array, and FTP'd the file back up.

After testing, I can now say with certainty that it <<<IS>>> necessary to change the @Referer array when using multiple domains (which is all I ever wanted to do three days ago). My form now works perfectly both at "mytopdomain.com" and at "onelowdomain.com".

I was, frankly, surprised at the Perl file format; looks a lot like an old Wordstar file. But, hey, that's their privilege.

I've been at this all night and bedtime is 'way overdue. Thanks again for all the help. I'm off to my next problem. :lol:

walt
02-15-2005, 06:57 AM
Well done, both of you!!!!!!

I'm finished. Problem solved; everything works perfectly. I will append my help ticket to let the people at WH know what we have learned.

I was never using WordPerfect to edit the .pl file; I was trying to do that using Site Manager's edit facility. (I use WordPerfect routinely for HTML, and would not want to give up the formatting & documentation capabilities there.) Jalal correctly discovered that it was saving the file in DOS format. (Actually, now that I have seen a proper Perl format, it appears to me that SM's editor was converting the file to DOS format when it opened, not when it saved. I didn't recognize that, because I had never seen a Perl file!)

I realized that I didn't really need to know how to run dos2unix. All I really needed to do was figure out how to download the .pl file, which I also had never done. I found an FTP download program, edited the file in Notepad to change the @Referer array, and FTP'd the file back up.

After testing, I can now say with certainty that it <<<IS>>> necessary to change the @Referer array when using multiple domains (which is all I ever wanted to do three days ago). My form now works perfectly both at "mytopdomain.com" and at "onelowdomain.com".

I was, frankly, surprised at the Perl file format; looks a lot like an old Wordstar file. But, hey, that's their privilege.

I've been at this all night and bedtime is 'way overdue. Thanks again for all the help. I'm off to my next problem. :lol:

jalal
02-15-2005, 09:26 AM
I'm glad you got it sorted out. Just one point I need to add, a recent discovery.


That said, running dos2unix does not seem to be doing anything. My screen blinks, the taskbar shows "done", but nothing appears in the "Results:" area. Is this normal?

When I look at the directory, the date does not change; more importantly, the form will not run.

I have tried these variations in the shell command line (all from the /cgi-bin/formmail/ directory:

dos2unix FormMail.pl
dos2unix -n FormMail.pl FormMail.plnew
dos2unix /var/www/cgi-bin/formmail/FormMail.pl


In fact, the little box that says "Execute Command" doesn't seem to do anything at all! And it is stuck in the TinySpice directory.
:o

I can only plead innocence in that I've never used the File Manager before... and now I know that I'll never use it again!

As Sunzon says, do your work locally, upload it through ftp and make sure that you save scripts in Unix format.

walt
02-15-2005, 02:44 PM
Part of my email to West Host:


I would suggest if the editor cannot edit Perl files, there ought to be a
stop built in to prevent an idiot (like me) from making this mistake (and
it's clearly my mistake; if I knew Perl, I would have recognized immediately
the file was being handled improperly). Something similar to how it throws
up a message on binary files would be a fine solution.

Of course, a better long-term solution would be to improve the editor so it
recognizes the .pl extension and saves the file properly.

And the reply from West Host:


The File manager has always converted the files to dos format and unfortunately this can not be changed. I highly suggest you use ftp to download any files to your machine and edit them instead of trying to edit them online, expecially scripts.

torrin
02-15-2005, 02:57 PM
Sounds like they might as well get rid of the edit part of site manager if it's not going to save files in the correct format.

walt
02-15-2005, 04:20 PM
Yeah; bummer WH reply, wasn't it?

I'll keep using it for HTML; it works fine there. It's quick and easy.