homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Perl mail problem

 4:50 pm on Sep 22, 2009 (gmt 0)

I have never worked with perl and I'm just trying to jerry rig it to an asp site. I have this script that someone else wrote. I had it working fine on our development server, but now it won't work on the live server. This script takes form input and sends an email. The funny thing is, it will send the email, but then the page just keeps loading and never prints out the success message. Here is the code. Does anyone have any pointers for me? I can tell you that the exact spot where the page will either send the email and load for forever, or not send the email is at the line where &mail(); is. Thanks,

# ---- Main program ----

my $query = new CGI;

if ($query->param) {
if ($query->param('max_resume_size')) {
$max_resume_size = $query->param('max_resume_size');

if ($query->param('domain')) {
$domain = $query->param('domain');

if ($query->param('redirect')) {
$redirect = $query->param('redirect');

if ($query->param('site_home')) {
$site_home = $query->param('site_home');
else {
if ($ENV{HTTP_REFERER} =~ /http:\/\/(.*?)\/(.*?)/i) {
$site_home = 'http://'.$1;
else {
if ($ENV{SCRIPT_NAME} =~ /http:\/\/(.*?)\/(.*?)/i) {
$site_home = 'http://'.$1;
else {
print $query->header(-cache => 'no');
print("<html><title><Error></title><body><h2>We are sorry but this is an invalid request.</h2></body></html>\n");

# Some logic to find the file name.. This assumes that the script file is placed
# in the same directory as the html file.

#Redundant method of finding file name of the application form.
#This always assumes that the file is in the same directory as form

my $file = "";


print '<CENTER><TABLE width="100%" border=0>' if ($MAIL{'debug'});
my @VAL = $query->param;

$MAIL{'message'} .= "\n--START_OF_DATA--\n\n";

my @emptyvariables;
foreach (@VAL) {
print '<tr><td align = left>',$_, '</td><td align=center> ====> </td><td align=left>', $query->param($_),'</td></tr>' if ($MAIL{'debug'});

if ($_ =~ /^\*(.+)/) {
if ((!$query->param($_)) ( $_ =~ /state/i && length($query->param($_)) ne 2)) {
push(@emptyvariables, $1 );

$MAIL{'message'} .= $_;
$MAIL{'message'} .= ' = ';
$MAIL{'message'} .= $query->param($_);
$MAIL{'message'} .= "\n";

print $query->header;
print '<h3><P>Thank you for your form submission. You will be hearing from us shortly.</P></h3>';
print "<P>Return to our <A HREF=\"$site_home\">Home Page</A>.</P>";
print $query->end_html;

[edited by: phranque at 11:28 pm (utc) on Sep. 22, 2009]
[edit reason] cleaned up extraneous comments [/edit]



 11:36 pm on Sep 22, 2009 (gmt 0)

have you looked in the server error log for clues?

for debugging purposes i would move the "print $query->header;" statement toward the beginning of the code.
if you print anything to STDOUT before the header your page won't display since it is not providing a proper HTTP response.

if it is hanging up in the "mail" routine that's a different issue, but you aren't showing that code so no way to tell.


 3:21 am on Sep 23, 2009 (gmt 0)

Thanks for the input, I will post more. I just didn't want to do a "code dump" because I know how annoying that it. I will post the whole script tomorrow. It's late (where I live) I had a bad day, and it's time for the bar. I'll be back tomorrow.


 6:55 am on Sep 23, 2009 (gmt 0)

please post only the relevant part of the script and leave out the extraneous comments.

WebmasterWorld Member Guidelines on Posting Code. [webmasterworld.com]


 1:38 pm on Sep 23, 2009 (gmt 0)

By server error log do you mean event viewer? Otherwise I'm not for sure what you mean. I am fairly certain it is hanging on the mail routine because if I comment out that one line then the success message gets printed, but of course, the email is not sent. If I leave it in, then the mail gets sent but nothing prints out. Any suggestions? Thanks.


 1:52 pm on Sep 23, 2009 (gmt 0)

So I restarted IIS and ran it again, and it worked instantly and fine. I appreciate your help though, I'm not going to lie, the "duct tape of the internet", that's so true.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved