tycoonbob Posted December 30, 2010 Share Posted December 30, 2010 Hello there. Let me start by saying that I am pretty much a PHP noobie. Coding/programming is not my thing, but I still know whats going on. To fill you in, I basically host a website off a server at home, running Apache2.2 and the latest PHP, and I have a feedback form on my website. The input boxes look correct, and so does the php script, however when you hit submit, the .php thinks it all went well, and displays the successfully sent page correctly, but I never get the message via email. Here is the .html code for what I have going on: <h1>Feedback Form</h1> <form action="feedback.php" method="post"> <table border="0" cellpadding="8" cellspacing="8"> <tr><td width="122"><label for="tswname">Name</label>:</td><td width="317"><input type="text" name="fullname" id="tswname" size="45" /></td></tr> <tr><td><label for="tswemail">Email address</label>:</td><td><input type="text" id="tswemail" name="email" size="45" /></td></tr> <tr> <td colspan="2"> <label for="tswcomments">Comments</label><br /> <textarea rows="15" cols="75" name="comments" id="tswcomments"></textarea> </td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Send Feedback" /><br /> </td> </tr> </table> </form> </p> Here is my .php script: <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'myemail@gmail.com' ; $subject = "Feedback Form" ; $formurl = "http://www.mysite.com/feedback.html" ; $errorurl = "http://www.mysite.com/error.html" ; $thankyouurl = "http://www.mysite.com/thankyou.html" ; $email_is_required = 1; $name_is_required = 1; $comments_is_required = 1; $uself = 0; $use_envsender = 0; $use_sendmailfrom = 0; $smtp_server_win = '' ; $use_webmaster_email_for_from = 0; $use_utf8 = 1; $my_recaptcha_private_key = '' ; // -------------------- END OF CONFIGURABLE SECTION --------------- define( 'MAX_LINE_LENGTH', 998 ); $headersep = (!isset( $uself ) || !$uself) ? "\r\n" : "\n" ; $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ; if (!isset( $use_envsender )) { $use_envsender = 0 ; } if (isset( $use_sendmailfrom ) && $use_sendmailfrom) { ini_set( 'sendmail_from', $mailto ); } if (isset( $smtp_server_win ) && strlen($smtp_server_win)) { ini_set( 'SMTP', $smtp_server_win ); } $envsender = "-f$mailto" ; $fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) { header( "Location: $errorurl" ); exit ; } if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) { header( "Location: $errorurl" ); exit ; } if (strlen( $my_recaptcha_private_key )) { require_once( 'recaptchalib.php' ); $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] ); if (!$resp->is_valid) { header( "Location: $errorurl" ); exit ; } } if (empty($email)) { $email = $mailto ; } $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ; if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "Name of sender: $fullname\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) . "\n\n------------------------------------------------------------\n" ; $headers = "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.0" . $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; if ($use_envsender) { mail($mailto, $subject, $messageproper, $headers, $envsender ); } else { mail($mailto, $subject, $messageproper, $headers ); } header( "Location: $thankyouurl" ); exit ; ?> I know I have seen plenty shorter scripts, so I wonder if mine is overkill for what I want it to do. It's that it's live on my site, and I am trying to figure out why it's not sending me any messages. My first assumption is an error with SMTP, as in if I have to configure something outside the script to make it send the message. Don't think there is any ports to be forwarded, but for testing purposes, my server is set as a DMZ locally right now. What is going wrong, or what did I not do? Thanks so much. Quote Link to comment https://forums.phpfreaks.com/topic/223004-question-about-this-feedback-forum/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.