kelly.payne171 Posted March 2, 2011 Share Posted March 2, 2011 Hi I was wondering if anybody could help me. I have used this form script on other hosting packages and it work well however I can not get it to work on Godaddy. I have not written the script i got it off the web and therefore i am having trouble implementing the advise from Godaddy. "It appears that the form in question allows you to define the To address for the message, but that in most cases the From address is designated as the email address entered by the party submitting the form. For anti-spam purposes, emails using a major provide as the From address (e.g. @hotmail, @gmail, @yahoo, etc) will often be rejected. As a result, we recommend that the From address for your message be a dedicated address utilizing your hosted domain; for example, contactform@your-directories.com. We recommend that you update your configuration to use a defined From address as previous indicated in order to resolve the issues which you are encountering" I guess what I am asking for is a fairy godmother/father to look at my code and tell me what I need to do to make it work. If anybody can help me I would be really greatful as I have been trying to make this work for day. Thanks for your time Kelly <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'kpayne@your-directories.com' ; $subject = "ContactForm" ; $formurl = "http://www.your-directories.com/contact.html" ; $thankyouurl = "http://www.your-directories.com/Forms/Thankyoucontact.html" ; $errorurl = "http://www.your-directories.com/Forms/Errorcontact.html" ; $email_is_required = 1; $name_is_required = 1; $comments_is_required = 1; $uself = 0; $use_envsender = 1; $use_sendmailfrom = 1; $smtp_server_win = '' ; $use_webmaster_email_for_from = 1; $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'] ; $phone = $_POST['phone'] ; $email = $_POST['email'] ; $department = $_POST['department'] ; $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" . "------------------------------------------------------------\n" . "Name of Sender: $fullname\n" ."------------------------------------------------------------\n" . "Phone Number of Sender: $phone\n" ."------------------------------------------------------------\n" . "Email of sender: $email\n" ."------------------------------------------------------------\n" . "For the Attention of Department: $department\n" . "------------------------- COMMENTS -------------------------\n\n" . "------------------------------------------------------------\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.1" . $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 ; ?> MOD EDIT: . . . tags added. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 2, 2011 Share Posted March 2, 2011 When posting code, please enclose it within the forum's . . . BBCode tags. Quote Link to comment Share on other sites More sharing options...
kelly.payne171 Posted March 3, 2011 Author Share Posted March 3, 2011 So sorry, it is my first time posting. Thanks. I would be really greatful if anybody coud help me with my original post Thanks for your time Kelly Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 add the from address here: $mailto = 'kpayne@your-directories.com' ; $subject = "ContactForm" ; $formurl = "http://www.your-directories.com/contact.html" ; $thankyouurl = "http://www.your-directories.com/Forms/Thankyoucontact.html" ; $errorurl = "http://www.your-directories.com/Forms/Errorcontact.html" ; $from = "webform@your-directories.com"; // assign the from address then further down... "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.1" . becomes "From: \"$fullname\" -via WebForm- <$from>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.1" . that should shut them up, and still have the script relay you the information that it originaly did, with the ability to use the "Reply" function still intact. Quote Link to comment Share on other sites More sharing options...
kelly.payne171 Posted March 3, 2011 Author Share Posted March 3, 2011 Thanks so much for taking the time to reply but it still doesn't work, do you have any other suggestions? Thanks again Kelly Quote Link to comment Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 Make sure the From address is a valid address on your email server. You may have to create this address. GoDaddy will not send an email, if the from header is NOT a valid email address on their server. They like to be ambiguous on this point. Quote Link to comment Share on other sites More sharing options...
kelly.payne171 Posted March 4, 2011 Author Share Posted March 4, 2011 Hi there, thank you for your reply I made sure both the email addresses (the email address the form gets sent to and the from email address) are valid addresses on the server but it still doesn't work. This is really frustrating as it looks like the form is being sent when on the site, I am not getting an error or anything, and when I asked GoDaddy the reply below was all they gave so I'm not 100% sure that is the problem. Should I be? Thank you for your time and any help will be greatly appreciated Kelly New code I am using: <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'kpayne@your-directories.com' ; $subject = "Contact Form" ; $formurl = "http://www.your-directories.com/contact" ; $thankyouurl = "http://your-directories.com/Forms/Thankyoucontact.html" ; $errorurl = "http://your-directories.com/Forms/Errorcontact.html" ; $from = "contactform@your-directories.com"; $email_is_required = 1; $name_is_required = 1; $comments_is_required = 1; $uself = 0; $use_envsender = 1; $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'] ; $phone = $_POST['phone'] ; $email = $_POST['email'] ; $department = $_POST['department'] ; $comments = $_POST['comments'] ; $code = $_POST['code'] ; $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" . "------------------------------------------------------------\n" . "Name of Sender: $fullname\n" ."------------------------------------------------------------\n" . "Phone Number of Sender: $phone\n" ."------------------------------------------------------------\n" . "Email of sender: $email\n" ."------------------------------------------------------------\n" . "For the Attention of Department: $department\n" . "------------------------- COMMENTS -------------------------\n\n" . "------------------------------------------------------------\n" . "------------------------------------------------------------\n" . wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) . "\n\n------------------------------------------------------------\n" ; $headers = "From: \"$fullname\" -via WebForm- <$from>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.1" . $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 ; ?> Quote Link to comment Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 mail will return false if the function fails. So, lets put a little de-bugging in there to see if it IS the SMTP server. if ($use_envsender) { if(!mail($mailto, $subject, $messageproper, $headers, $envsender )) echo 'Mail ran under 5 arguments has failed!'; } else { if(!mail($mailto, $subject, $messageproper, $headers )) echo 'Mail ran under 4 arguments has failed!'; } header( "Location: $thankyouurl" ); exit ; If you get one of the messages, it means PHP did NOT successfully send it to the email server. No message means that the server received it. Quote Link to comment Share on other sites More sharing options...
kelly.payne171 Posted March 4, 2011 Author Share Posted March 4, 2011 Hi its still the same, no error message and no email Thanks for all your help its greatly appreciated I will post my code to make sure I implemented it properly. Kelly <?php // ------------- CONFIGURABLE SECTION ------------------------ $mailto = 'kpayne@your-directories.com' ; $subject = "Contact Form" ; $formurl = "http://www.your-directories.com/contact" ; $thankyouurl = "http://your-directories.com/Forms/Thankyoucontact.html" ; $errorurl = "http://your-directories.com/Forms/Errorcontact.html" ; $from = "contactform@your-directories.com"; $email_is_required = 1; $name_is_required = 1; $comments_is_required = 1; $uself = 0; $use_envsender = 1; $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'] ; $phone = $_POST['phone'] ; $email = $_POST['email'] ; $department = $_POST['department'] ; $comments = $_POST['comments'] ; $code = $_POST['code'] ; $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" . "------------------------------------------------------------\n" . "Name of Sender: $fullname\n" ."------------------------------------------------------------\n" . "Phone Number of Sender: $phone\n" ."------------------------------------------------------------\n" . "Email of sender: $email\n" ."------------------------------------------------------------\n" . "For the Attention of Department: $department\n" . "------------------------- COMMENTS -------------------------\n\n" . "------------------------------------------------------------\n" . "------------------------------------------------------------\n" . wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) . "\n\n------------------------------------------------------------\n" ; $headers = "From: \"$fullname\" -via WebForm- <$from>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.1" . $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; if ($use_envsender) { if(!mail($mailto, $subject, $messageproper, $headers, $envsender )) echo 'Mail ran under 5 arguments has failed!'; } else { if(!mail($mailto, $subject, $messageproper, $headers )) echo 'Mail ran under 4 arguments has failed!'; } header( "Location: $thankyouurl" ); exit ; ?> Quote Link to comment Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 I would contact the host, and tell them you have changed your code to abide by their policies. Yet, it still isn't sending mail. They can look in their error logs and see what the problem is. Quote Link to comment Share on other sites More sharing options...
kelly.payne171 Posted March 4, 2011 Author Share Posted March 4, 2011 Thanks will do Quote Link to comment 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.