Lunarpages Web Hosting Forum

Author Topic: - Bad Gateway????  (Read 30206 times)

Offline Comet Software

  • Spacescooter Operator
  • *****
  • Posts: 40
Re: - Bad Gateway????
« Reply #30 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?

Offline Comet Software

  • Spacescooter Operator
  • *****
  • Posts: 40
Re: - Bad Gateway????
« Reply #31 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

The "Address" box in my browser has:

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 "" 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 = '';

These lines are in my html file:

<form name="contact_us" id="contact_us" method="post" action="/cgi-bin/">
<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:

Offline Comet Software

  • Spacescooter Operator
  • *****
  • Posts: 40
Re: - Bad Gateway????
« Reply #32 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?

Offline craverii

  • Newbie
  • *
  • Posts: 1
    • PixelVision
Re: - Bad Gateway????
« Reply #33 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----

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;

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

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'};

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

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



Offline webgeeko

  • Newbie
  • *
  • Posts: 1
Re: - Bad Gateway????
« Reply #34 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]
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 = '';
Replace 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: