Jump to content

PHP Form Script and Godaddy


kelly.payne171

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 ;

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.