0

When I upload this site's folder to my own testing site it works fine, however when I upload to the client's site the email doesn't get sent. The form appears to work and brings me to the thank you page but no email is sent.

this is the php:

<?php
$webmaster_email = "sarahtrafford@me.com";

$feedback_page = "feedback_form.html";
$error_page = "error_message.html";
$thankyou_page = "thank_you.html";

$email_address = $_REQUEST['email_address'] ;
$comments = $_REQUEST['comments'] ;

function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
    return true;
}
else {
    return false;
}
} 

// If the user tries to access this script directly, redirect them to the feedback     form,
if (!isset($_REQUEST['email_address'])) {
header( "Location: $feedback_page" );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( "Location: $error_page" );
}

// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( "Location: $error_page" );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( "$webmaster_email", "Feedback Form Results",
$comments, "From: $email_address" );
header( "Location: $thankyou_page" );
}
?>

this is the form code in the html

<form action="send_mail.php" method="post" id="drop_form">

<label for="email">E-mail<span>*</span></label><br>
<input type="text" name="email_address" value="" maxlength="90" /><br>

<label for="message_box">Message<span>*</span></label><br>
<textarea rows="7" cols="37" name="comments" id="message_box"></textarea>

<div id="submit_form">
<input type="submit" value="Submit" class="form_btn"/>
</div>

</form>

Is there something I may need to do in their server? I uploaded it the same way in my own and it worked fine there.

saraht
  • 39
  • 1
  • 1
  • 8
  • Are you getting errors in your logs? Have you verified that whatever your mail-sending mechanism (i.e. sendmail) actually works for this server independently of PHP? – Mike Brant Dec 06 '13 at 19:50
  • I don't know a lot of back end. There are no logs, all I know is I created the site and uploaded it onto my own web site's server and everything worked but when I uploaded it to the client's site the email no longer sends. – saraht Dec 06 '13 at 19:52
  • 1
    mail() is pretty useless when it comes to being insightful. You should look at using another mail library that can give you better tools. Check out [Swift Mailer](http://swiftmailer.org/) – thatonefreeman Dec 06 '13 at 19:56
  • @sarht The a many reasons that a mail may not send. It could by some in PHP configuration for `mail()` it could be the mailing service is not set up properly, it could be that the mail actually got sent by the server but the the SMTP relay was not configured correctly and got the mail blocked, etc. At a minimum you need to get on that box and start looking at the mail queue and PHP configurations. You should also check the value returned by `mail()` function as well. This will immediately tell you if PHP thinks the mail was sent. – Mike Brant Dec 06 '13 at 19:57

0 Answers0