I have not been able to get my mail form to send messages to my email. The thank you page pops up after I test it, but nothing is sent. I use GoDaddy, so I'm not sure if that is part of the problem. This is my first attempt at PHP, so I don't know what I'm doing! I got the code from the Site Wizard. Any help would be great!
Here is the code in my HTLM page for the form:
<div id="package">
<fieldset id="personalinfo">
<legend class="perlegend"><img src="Art/header_contact.png" class="perlegendheader" >
<div id="collage"></div>
</legend>
<p> </p>
<form action="gdform.php" method="post">
<input type="hidden" name="redirect" value="thankyou.html" />
<p>
<label for="name"> Name</label>
<br>
<input name="name" type="text"/>
</p>
<p>
<label for="email">Email</label>
<span class="required">(required)</span><br>
<input name="email" type="text"/>
</p>
<p>
<label class="top" for="comments">Message</label>
<br>
<textarea name="comments" cols="32" rows="5"></textarea>
</p>
<p>
<input name="Submit" type="submit" class="submit" value="SEND"/>
</p>
</form>
<br class="clear" />
</p>
</fieldset >
<br>
</div>
Here is my PHP code (without my real email address):
<?php
// ------------- CONFIGURABLE SECTION ------------------------
$mailto = 'XXX@gmail.com' ;
$subject = "Message from Martha Berry Design" ;
$formurl = "http://www.marthaberrydesign.com/contact.html" ;
$errorurl = "http://www.marthaberrydesign.com/error.html" ;
$thankyouurl = "http://www.marthaberrydesign.com/thankyou.html" ;
$email_is_required = 1;
$name_is_required = 0;
$comments_is_required = 0;
$uself = 0;
$use_envsender = 0;
$use_sendmailfrom = 1;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$my_recaptcha_private_key = '' ;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\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 );
}
$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" .
$comments .
"\n\n------------------------------------------------------------\n" ;
$headers =
"From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.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 ;
?>