Lunarpages Web Hosting Forum

Scripting Languages Hosting Help => C++ / PERL / CGI Support => Topic started by: S13D on July 13, 2006, 03:44:33 PM

Title: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 03:44:33 PM
I've been having problems with the formmail.pl script. Will someone please help me??? Thanks in advance!!!

LINK TO FORM: http://www.mytourvision.com/contact_us.htm

SEE CONFIG BELOW:

BEGIN
{
  $DEBUGGING         = 1;
  $emulate_matts_code= 0;
  $secure            = 1;
  $allow_empty_ref   = 1;
  $max_recipients    = 1;
  $mailprog          = '/usr/sbin/sendmail -oi -t';
  $postmaster        = '';
  @referers          = qw(mytourvision.com localhost);
  @allow_mail_to     = qw(feedback@mytourvision.com localhost);
  @recipients        = ();
  %recipient_alias   = ();
  @valid_ENV         = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
  $locale            = '';
  $charset           = 'iso-8859-1';
  $date_fmt          = '%A, %B %d, %Y at %H:%M:%S';
  $style             = 'http://www.mytourvision.com/css/tourvision.css';
  $no_content        = 0;
  $double_spacing    = 1;
  $wrap_text         = 0;
  $wrap_style        = 1;
  $address_style     = 0;
  $send_confirmation_mail = 0;
  $confirmation_text = <<'END_OF_CONFIRMATION';
From: feedback@mytourvision.com
Subject: Customer Feedback

Thank you for your form submission. TOUR VISION will review it and respond shorly...

END_OF_CONFIRMATION

# You may need to uncomment the line below and adjust the path.
# use lib './lib';

Title: Re: FormMail.pl - Bad Gateway????
Post by: Lupine1647 on July 13, 2006, 03:59:20 PM
Hello:
Please see http://www.lunarforums.com/forum/index.php?topic=18221.0
The FormMail.pl file name is not allowed.

I hope this helps.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:01:01 PM
sorry about that... it's actually called feedback.pl on the server. just used that to reference the file in the forum. any thoughts?

i've been reviewing the link you sent me all day. not sure what the problem is... at one point i was able to get the script to send mail to the account but then got error messages... now i'm getting Bad Gateway message for some reason? i'm reviewing the link now. thanks for the the link though. the forum is excellent.

this is my second post!!!
Title: Re: FormMail.pl - Bad Gateway????
Post by: Lupine1647 on July 13, 2006, 04:13:19 PM
Hello:
I'm not sure what might be causing it, but you should use a file name that is less obvious to prevent bot attacks on the script.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:14:33 PM
will change it to something less obvious. thanks for the TIP...
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 04:18:02 PM
Remove the following tag completely from your html form:

Code: [Select]
<input type="hidden" name="recipient">
I've never seen that particular error message before, but the above "recipient" tag shouldn't even be in your html unless you are going to use it with a "value" (as shown in the examples for multiple email addys).
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:22:35 PM
i'm taking it out now. nothing happened. still getting Bad Gateway...
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 04:26:13 PM
Are you on a Windows server?

I'm currently looking up that error message via Google to see if there's any info on what that means. You might do the same in case you find it faster.
Title: Re: FormMail.pl - Bad Gateway????
Post by: Lupine1647 on July 13, 2006, 04:28:00 PM
Hello:
mytourvision.com is on a Windows server.

I hope this helps.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:34:53 PM
FOUND THIS...

10.5.3 502 Bad Gateway

The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

AND THIS...

502 - Bad Gateway. Web server received an invalid response while acting as a gateway or proxy. You receive this error message when you try to run a CGI script that does not return a valid set of HTTP headers.

here: http://kb.globalscape.com/article.aspx?id=10141

I remember about reading something about HEADERS messing up email servers? any thoughts???
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 04:42:58 PM
Did you delete/erase any portion of the script?

If you did (or even if you didn't), reconfigure a fresh copy as your existing one might be corrupted.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:47:55 PM
i've tried that 4 different times. i didn't delete anything. i've renamed it. flip-flopped email addresses, compared my script to others on the forum. nothing seems to be working... not sure why... got any other suggestions?
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 04:49:33 PM
mytourvision.com is on a Windows server.

Ahh, I missed Ryan's post earlier, but this may be the problem.

The shebang line and path to sendmail or SMTP is probably going to be different  for using the perl script on a Windows server.

I'm not familiar with what those configs are. You will need to do a search for how to configure the settings for a Windows server, or if you can't find any info and nobody else posts here who knows the answer, then see if tech support may give you help with that.
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 04:54:35 PM
P.S. If you do find out what the configs are, please post the answer here so I can revise my tutorial in case other people on a Windows server needs the info. Thanks!
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 04:55:26 PM
cheers!  :thumb:
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 05:17:30 PM
Try this while you're waiting:

Shebang line (the top most line of the .pl script):

#!C:/www/perl/bin/perl.exe

OR

#!perl.exe

Then try changing the $mailprog part of the CONFIGURATION in the script to your domain name like so:

Code: [Select]
$mailprog = 'SMTP:yourdomain.com';
I'm still looking for other possible solutions in case none of those work, but try those in the meantime  :)

I hope tech support knows the answer though, cuz that would make life so much easier  :yep:
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 13, 2006, 05:23:47 PM
just sent tech support an email regarding this matter. thanks for your help! i REALLY appreciate it. :yey:
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 13, 2006, 05:56:47 PM
 :) okay great, hope there's an answer.

Just for the heck of it though, I found one more possible way to write the shebang line for a Windows server, so replace the very first/top line of the script to:

Code: [Select]
#!C:/perl/bin/perl.exe
I'm pretty sure that with the right shebang line and changing the $mailprog to your SMTP, that should do it  :). In the CONFIGURATION section, change the $mailprog to this:

Code: [Select]
$mailprog = 'SMTP:yourdomain.com';
Replace yourdomain.com with your domain name.

* Edited - Okay, I tested out the SMTP part on my server and that works (using the code I gave above for the $mailprog bypasses using sendmail), so the only thing that is needed is the path to perl for the script to work on Windows server.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 19, 2006, 12:20:49 AM
just wanted to thank you for your help. i've been away and didn't have time to test. after reading your post, it works! i owe ya a beer.  :thumb:
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 19, 2006, 01:19:07 AM
That's GREAT! (I'm referring to about it working and not the beer, lol  :))

Which shebang line worked, so I can revise my tutorial to include it for Windows Server users.
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 19, 2006, 02:22:27 AM
shebang = #!C:/perl/bin/perl.exe

after unsuccessful attempts in two different FTP programsi'm getting this when i try to change the permissions of the .pl file...

> SITE CHMOD 755 sendtome2.pl
< 500 'SITE CHMOD 755 sendtome2.pl': command not understood

i've downloaded two different FTP programs (CuteFTP and LeechFTP) hoping one would work. unfortunately i've been unsuccessfull with both FTP programs and with "Plesk Control Panel>File Nanager". the permissions i get are 777 by default and stay the same after i change them to 755... any thoughts?

i've reviewed this: http://www.lunarforums.com/forum/index.php?topic=18221.msg218534#msg218534
Title: Re: FormMail.pl - Bad Gateway????
Post by: GMTurner on July 19, 2006, 05:49:47 AM
I believe the permission issue applies to the linux based plans but is a completely different animal on the windows plans because of how file permissions are handled. If it is working without needing to change permissions, then there is no reason to change what is working. :)
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on July 19, 2006, 10:26:32 AM
I found this Plesk tutorial via Google. I'm sure you did it this way, but take a look at it anyway:

http://forum.mamboserver.com/showthread.php?t=81017

You see where it says "Permissions" in the File Manager? Look to see what that already says first, because in the past there was someone who had the same issue thinking that they had kept changing the permissions to 755 but it wasn't changing, but in actuality, it was already changed after they looked at the tiny numbers on the side of the file in cPanel.

Plesk looks like it doesn't show numbers next to the file (like cPanel does), but it shows the rw-r-r thingys.

Sometimes the programs (FTP especially) do not show what the actual permissions that are already set on the file is when opening their chmod settings thingys, so it throws you off thinking it's not changed when it really is :)
Title: Re: FormMail.pl - Bad Gateway????
Post by: S13D on July 24, 2006, 12:24:38 AM
i appreciated everyone's help on this matter.  :thumb:
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on September 26, 2006, 07:06:13 PM
You see where it says "Permissions" in the File Manager? Look to see what that already says first, because in the past there was someone who had the same issue thinking that they had kept changing the permissions to 755 but it wasn't changing, but in actuality, it was already changed after they looked at the tiny numbers on the side of the file in cPanel.

Plesk looks like it doesn't show numbers next to the file (like cPanel does), but it shows the rw-r-r thingys.

I am a new domain here and trying to get FormMail to work.  I am trying to set the permission, but, the "Permissions" panel is different from what is described above.  I am assuming that there is a new version of Plesk.  I don't know how/why I need to differentiate permissions between "Group or user names".  Any help?
Title: Re: FormMail.pl - Bad Gateway????
Post by: GMTurner on September 26, 2006, 07:17:31 PM
the part you quoted is referring to cPanel on the linux plans, not plesk which is on the windows plans... which is why it looks different and is a bit confusing to follow in relation to the tutorial :)

From what I recall, you might not need to change permissions on the file... are you getting an error message when you try to use it?
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on September 26, 2006, 07:20:37 PM
Marc, it is Plesk that he was quoting my post with. Read my whole post :)

Comet, someone on Plesk will have to help you with that, as those of us on cPanel won't know how Plesk on the Window's plan looks.
Title: Re: FormMail.pl - Bad Gateway????
Post by: leighsww on September 26, 2006, 09:29:48 PM
Oh, but I want to add ...

Marc/GMTurner is correct that you may not need to change the permissions for the .pl file on the Windows server (since S13D had mentioned that his form worked before he was attempting to change the permissions), so please link us to your form so we can test it to see what error you are receiving, thus help you better.
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on October 08, 2006, 04:45:06 PM
the part you quoted is referring to cPanel on the linux plans, not plesk which is on the windows plans... which is why it looks different and is a bit confusing to follow in relation to the tutorial :)

That's odd, cus I have a Windows plan.


From what I recall, you might not need to change permissions on the file... are you getting an error message when you try to use it?

Not yet.  When I made the first post, my DNS had not been changed and I was trying to upload everything so that I could test it when the DNS was changed.
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on October 08, 2006, 04:47:08 PM
Comet, someone on Plesk will have to help you with that, as those of us on cPanel won't know how Plesk on the Window's plan looks.

OK, color me a confused new user.  From my "Customer Pages", I click on "Control Panel" and it takes me to a Plesk application.  So, where do I get/use cPanel?
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on October 08, 2006, 06:43:01 PM
the part you quoted is referring to cPanel on the linux plans, not plesk which is on the windows plans... which is why it looks different and is a bit confusing to follow in relation to the tutorial :)

That's odd, cus I have a Windows plan.

OK, I reread this and i think I follow now.  The tutorial tells how to set this up via cPanel which is an app for Linux servers.  And, since I have a Windows plan, I have Plesk.  But, as i recall, the tutorial makes reference to some differences between Linux and Windows hosting, but, doesn't mention Plesk.

I guess a place to restart now would be to ask the question:  do I have to set permissions for the file if I have Windows hosting?  If so, how do I do that?
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on October 09, 2006, 03:30:28 PM
OK, my domain has finally transferred, so, I can test this for real now.

When I click on my form's "submit" button, I get a web page that says:

502 Bad Gateway
Web server received an invalid response while acting as a gateway or proxy server.
Web Server at cometsoftware.com

The "Address" box in my browser has:

http://www.cometsoftware.com/cgi-bin/x123.pl


I have gone back and read over this thread and the "Can't quite figure out FormMail", and, I still can't get it to work (and, I'm not sure how this thread originator resolved his error).  So, let me review what I have and what I have done.


I am a new domain at Lunarpages on a Windows server.  My script is named "x123.pl" and was transferred via FTP "ASCII" to my domain's "cgi-bin" folder.  Perl is enabled for my domain.  These lines are in the configuration portion of the script:

shebang = #!C:/perl/bin/perl.exe
$mailprog = 'SMTP:cometsoftware.com';


These lines are in my html file:

<form name="contact_us" id="contact_us" method="post" action="/cgi-bin/x123.pl">
<input type="hidden" name="subject" value="Contact Us" />
<input type="hidden" name="required" value="realname,email,yourcomment" />
<input type="hidden" name="redirect" value="contact_us_success.htm" />


All of the "help" I have found for setting file permissions in Plesk seem to be referring to an older version than the one I am using.  So, I don't know what the script's permissions are, or are supposed to be, for the "Group or user names" panel.

I don't know where to go from here   :help:
Title: Re: FormMail.pl - Bad Gateway????
Post by: Comet Software on October 16, 2006, 02:41:51 PM
OK, i guess FormMail doesn't work on LP Windows hosting.

Anybody have suggestions for an alternative?
 
Title: Re: FormMail.pl - Bad Gateway????
Post by: craverii on October 29, 2006, 07:37:22 PM
I really believe that the best way to handle form mailing is by creating your own simple mail client in perl, bypassing sendmail altogether.  Below is a sample script.  values inside of
braces ([...]) are meant to be replaced with your specific values.

----BEGIN CODE----
#!/usr/bin/perl

use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:cgi-lib -no_xhtml/;
use Mail::Mailer;

### User definable variables
my $mailhost = 'localhost';
my $mail_recipient = '[your_email@yourdomain]';
my $subject = '[Your Subject Line]';
###

my $cgi = new CGI;
send_email();

# This redirects clients to a prefabricated page upon completion, but
# it could just as easily be made to generate HTML output as a result.
redirect_client();

sub send_email {
    # All of the form variables are in the hash %form_vars.  Each form control name
    # is a key in the hash, e.g. $$form_vars{'email'}, 'email' being the form control name.
    my $form_vars = Vars;
    my $mailer = Mail::Mailer->new();
    $mailer->open({ From    => $$form_vars{'email'},
                    To      => $mail_recipient,
                    Subject => $subject,
                  })
        or die "Can't open: $!\n";
    print $mailer $$form_vars{'comments'};
    $mailer->close();
}

sub redirect_client {
    print $cgi->redirect('http://[yourdomain]/thankyou.html');
}

exit 0;
----END CODE----

Regards,

Rob
Title: Re: FormMail.pl - Bad Gateway????
Post by: webgeeko on October 04, 2009, 01:52:21 AM
:) okay great, hope there's an answer.

Just for the heck of it though, I found one more possible way to write the shebang line for a Windows server, so replace the very first/top line of the script to:

Code: [Select]
#!C:/perl/bin/perl.exe
I'm pretty sure that with the right shebang line and changing the $mailprog to your SMTP, that should do it  :). In the CONFIGURATION section, change the $mailprog to this:

Code: [Select]
$mailprog = 'SMTP:yourdomain.com';
Replace yourdomain.com with your domain name.

* Edited - Okay, I tested out the SMTP part on my server and that works (using the code I gave above for the $mailprog bypasses using sendmail), so the only thing that is needed is the path to perl for the script to work on Windows server.

Thank you soooooooooooooo much............. this works.  :yey: