I can't figure this out. No errors appear and it redirects back to the page it's supposed to. It's supposed to email the admin and send a thank you email to the one who filled out the contact form.

Neither emails are sent or recieved but it seems to be fine (it loads, processes and redirects without a problem). Any idea what might be causing this?

#!/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); ####################################### # Configuration section # ####################################### my $admin_mail = 'my@email.com'; # change the above to the email address of the administrator my $sendmail = '/usr/lib/sendmail'; # change the above to the location of sendmail on the server my $thank_you_msg = 'Dear Client,\nThank you for contacting Ufly4less. + We aim to respond to all enquires within 1 working day.\n\nRegards,\ +nThe Ufly4less Team\n\n100% committed to finding you cheap fares, everytime!'; # change the above to the thank you message you want to send # your visitors. Add a \n anywhere you want in the message # to create new lines. \n\n would make a double space. my $redirect_url = 'http://www.ufly4less.com/default'; # change the above to the page you want to redirect to ####################################### # Do not edit below this line # ####################################### ######## # This section only initates when the form was submitted ######## if (param()) { print header; my $name = param("name"); my $organisation = param("organisation"); my $address = param("address"); my $town = param("town"); my $county = param("county"); my $postcode = param("postcode"); my $phone = param("phone"); my $email = param("email"); my $message = param("other"); ###### # make sure our required fields are filled out ###### if ($name eq "") { &reqerror("name"); } if ($phone eq "") { &reqerror("phone"); } if ($postcode eq "") { &reqerror("postcode"); } if ($email eq "") { &reqerror("email");} ###### # Email function starts here ###### open(MAIL,"| $sendmail") or die "Can't open $sendmail sendmail beca +use: $!"; print MAIL "To: $admin_mail\n"; print MAIL "From: $email\n"; print MAIL "Subject:Website Enquiry\n"; print MAIL "Contact Name: name\n"; print MAIL "Enquiry Type: $organisation\n"; print MAIL "Address: $address\n"; print MAIL "Town: $town\n"; print MAIL "Postcode: $postcode\n"; print MAIL "County: $county\n"; print MAIL "Phone: $phone\n"; print MAIL "Email: $email\n\n"; print MAIL "Other Details: $message\n"; print MAIL "\n\n"; close(MAIL); open(MAIL,"| $sendmail") or die "Can't open $sendmail sendmail beca +use: $!"; print MAIL "To: $email\n"; print MAIL "From: $admin_mail\n"; print MAIL "Subject:Ufly4Less Website Enquiry\n"; print MAIL "$thank_you_msg \n\n\n"; print MAIL "\n\n"; close(MAIL); ###### # Printout of confirmation page ###### print <<" END"; <HTML> <head> <title></title> <meta http-equiv="refresh" content="1;url=$redirect_url"> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" ali +nk="red"> <p>Thank you for your message. You are now being redirected.</ +p> </body> </HTML> END exit; } ####### # If this section is activated, no form data was submitted ####### else { print header, start_html(); print qq(<font color="red"><b>ERROR:</b></font> This page cannot be + accessed directly. Action cancelled.); exit; } #################### # Error sub routine found below #################### sub reqerror { print header, start_html(); my $error = shift; print qq(<font color="red"><b>ERROR!</b> The field $error was left +blank and is a required field. Please click back to try again.); exit; }

Edit g0n - added readmore tags


In reply to contact form not mailing (urgent!) by coldfingertips

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.