当我将此网站的文件夹上传到我自己的测试网站时,它工作正常,但是当我上传到客户端的网站时,电子邮件不会被发送。该表单似乎有效,并将我带到感谢页面,但没有发送电子邮件。
这是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" );
}
?>
这是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>
我的服务器中可能需要做些什么吗?我以同样的方式在我自己上传它,它在那里工作得很好。