PHP电子邮件表单错误
我的PHP发送表单遇到一些问题。按下提交按钮时,我不会收到电子邮件。然而,我确实进入了“成功”页面 有人能看看我的档案吗 提前谢谢 Contact.phpPHP电子邮件表单错误,php,html,email,Php,Html,Email,我的PHP发送表单遇到一些问题。按下提交按钮时,我不会收到电子邮件。然而,我确实进入了“成功”页面 有人能看看我的档案吗 提前谢谢 Contact.php <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Contact I Messenbrink.eu</title> <link href="_css/main.css" rel="styleshe
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Contact I Messenbrink.eu</title>
<link href="_css/main.css" rel="stylesheet" type="text/css">
<link href="_css/contact.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Quattrocento+Sans' rel='stylesheet' type='text/css'>
<!-- Internet Explorer HTML5 enabling script: -->
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<style type="text/css">
.clear {
zoom: 1;
display: block;
}
</style>
<![endif]-->
<!--<script src="js/jquery.placeholder.js"></script>
<script src="js/modernizr-min.js"></script>
<script>
if (!Modernizr.input.placeholder){
$('input[placeholder], textarea[placeholder]').placeholder();
}
</script>
<script src="js/jquery.form.js"></script>
<script src="js/jquery.validate.js"></script>
<script>
$(function(){
$('#contact').validate({
submitHandler: function(form) {
$(form).ajaxSubmit({
url: 'process.php',
success: function() {
$('#contact').hide();
$('#contact-form').append("<p class='thanks'>Thanks! Your request has been sent.</p>")
}
});
}
});
});
</script>-->
</head>
<body>
<section id="page"> <!-- Defining the #page section with the section tag -->
<header> <!-- Defining the header section of the page with the appropriate tag -->
<hgroup>
<img id="logo" src="_Images/Logo_messenbrink_tryout.png" height="45"/>
<h3>Film · Photography · Graphic · Web</h3>
</hgroup>
<div class="socialbuttons">
<div id="email_button"><a href="Contact.html"><img src="_Images/SocialButtons/email.png" /></a></div>
<div id="deviant"><a href="http://messenbrink.deviantart.com/gallery/"><img src="_Images/SocialButtons/deviant.png" /></a></div>
<div id="social_facebook">
<div id="facebook_like_button_holder">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.messenbrink.eu" send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like>
<div id="fake_facebook_button"></div>
</div>
<script type="text/javascript">
FB.Event.subscribe('edge.create', function(response) {
window.location = "http://www.messenbrink.eu";
});
</script>
</div>
<div id="custom_twitter_button">
<a href="https://twitter.com/share?url=https%3A%2F%2Fdev.twitter.com%2Fpages%2Ftweet-button" target="_blank"></a>
<!-- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
--> </div>
<!-- <div id="stumble">
<div id="stumble_button_holder">
<su:badge layout="6"></su:badge>
</div>
<div id="stumble_button_new" style="background-image:url(_Images/SocialButtons/stumble.png); background-size:24px;"></div>
<script type="text/javascript">
(function() {
var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
li.src = 'https://platform.stumbleupon.com/1/widgets.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
})();
</script>
</div>
-->
</div>
<?php include("includes/navigation.php");?>
<div id="n1"/>
</header>
<section id="articles"> <!-- A new section with the articles -->
<!-- Article 1 start -->
<article id="article1"> <!-- The new article tag. The id is supplied so it can be scrolled into view. -->
<!--Contact Form-->
<!--Contact Form-->
<div id="contact-form">
<form id="contact_messenbrinkeu" action="sendform.php" method="post">
<fieldset id="form">
<label for="name">Name</label><br>
<input type="text" name="name" placeholder="Your Name"title="enter your name" class="alpha required"><br>
<label for="email">E-mail</label><br>
<input type="email" name="email" placeholder="mail@example.com" title="Enter your e-mail address" class="mail required"><br>
<label for="phone">Phone</label><br>
<input type="text" name="phone" placeholder="+45 12 34 56 78" class="numeric"><br>
<label for="website">Website</label><br>
<input type="text" name="website" placeholder="www.example.com" id="website"><br>
<label for="message">Message</label><br id="message">
<textarea name="message" class="required"></textarea>
</fieldset>
<fieldset id="button">
<button type="submit">>> Send</button>
<button type="reset">reset <<</button>
</fieldset>
</form>
</div><!-- /end #contact-form -->
</article><!-- Article 1 end -->
</section>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery.noConflict();
jQuery(document).ready(function($){
// when submit button is pressed
$("#contact_messenbrinkeu").submit(function() {
var pass = true;
var errors = {
required : 'this field is required',
email : 'enter a valid email address',
numeric : 'enter a number without spaces, dots or commas',
alpha : 'this field accepts only letters & spaces'
};
var tests = {
email : /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
numeric : /^[0-9]+$/,
alpha : /^[a-zA-Z ]+$/
};
// clear error messages
$(".error").removeClass();
$(".error-message").remove();
function displayError(el, type) {
$(el).parent().addClass("error").find('label').append('<span class=\"error-message\"> – ' + errors[type] + '</span>');
}
$('.required, .email, .numeric, .alpha').each(function(){
var value = $(this).val();
var valueExists = value.length === 0 ? false : true;
var required = $(this).hasClass('required');
var email = $(this).hasClass('email');
var numeric = $(this).hasClass('numeric');
var alpha = $(this).hasClass('alpha');
if (required && value.length===0) {
displayError(this,'required');
pass=false;
}
else if (email && valueExists && !tests.email.test(value)) {
displayError(this,'email');
pass=false;
}
else if (numeric && valueExists && !tests.numeric.test(value)) {
displayError(this,'numeric');
pass=false;
}
else if (alpha && valueExists && !tests.alpha.test(value)) {
displayError(this,'alpha');
pass=false;
}
});
return pass;
});
});
/*]]>*/
</script>
</body>
</html>
联系I Messenbrink.eu
电影&米德多;摄影与米德;图形和middot;网状物
FB.Event.subscribe('edge.create',函数(响应){
window.location=”http://www.messenbrink.eu";
});
";
#开始状态
$valid=true;
#循环遍历错误类型的字段
foreach($validate as$type=>$fields){
#循环通过要测试的字段的值
foreach($value形式的字段){
#如果值是必需的且未输入,则抛出错误
如果($type=='required'&&strlen($value)==0){
$errorMarkup.=“$errorsMsgs[$type] ”;
$valid=false;
打破
}
否则如果(
$type==='validEmail'&&!filter\u var($value,filter\u VALIDATE\u EMAIL)||
$type=='validNumber'&&!preg_match('/^[0-9]+$/',$value)||
$type==='validAlpha'&&!preg_match('/^[a-zA-Z]+$/',$value)
) {
如果(strlen($value)==0){break;}#如果未输入值,则跳过检查
$errorMarkup.=“\”$value\“$errorsMsgs[$type] ”;
$valid=false;
继续;
}
}
}
如果($有效){
sendMail();
$body=$successMarkup.$backMarkup;
$title=“已发送表格”;
}否则{
$body=$errorMarkup.$errorMarkupEnd.$backMarkup;
$title=“表单错误”;
}
#编写html输出
回音“$titlebody{margin:100px;font:16px/1.5无衬线;颜色:#111}h1{font size:32px;margin:0;font-weight:bold}h2{font-size:18px;margin:020px 0}ol,li{列表样式位置:内部;左填充:0;左边框:0}$body”;
?>
您缺少一些标题信息,这些信息将使您的电子邮件更加合法(如MIME版本、内容类型等),因此该邮件可能被标记为来自exchange服务器的垃圾邮件,无法到达目的地。这是我使用的功能,它甚至成功地传递了Hotmail、Gmail和Yahoo邮件
function mailme($sendto,$sendername,$from,$subject,$sendmailbody,$bcc="")
{
$subject = nl2br($subject);
$sendmailbody = nl2br($sendmailbody);
if($bcc!="")
{
$headers = "Bcc: ".$bcc."\n";
}
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8 \nContent-Transfer-Encoding: 8bit\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP/"."MIME-Version: 1.0\n";
$headers .= "From: " . $from . "\n";
$headers .= "Content-Type: text/html\n";
mail("$sendto","$subject","$sendmailbody","$headers");
}
我建议您启用错误报告和日志记录。请参阅
- PHP文件:
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('log_errors', true);
ini_set('error_log', '/path/to/php.log');
- .htaccess:
php_value error_reporting 65535
php_flag display_errors On
php_flag log_errors On
php_value error_log /path/to/php.log
- PHP文件:
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('log_errors', true);
ini_set('error_log', '/path/to/php.log');
- .htaccess:
php_value error_reporting 65535
php_flag display_errors On
php_flag log_errors On
php_value error_log /path/to/php.log
- PHP文件:
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('log_errors', true);
ini_set('error_log', '/path/to/php.log');
- .htaccess:
php_value error_reporting 65535
php_flag display_errors On
php_flag log_errors On
php_value error_log /path/to/php.log
- PHP文件:
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('log_errors', true);
ini_set('error_log', '/path/to/php.log');
- .htaccess:
php_value error_reporting 65535
php_flag display_errors On
php_flag log_errors On
php_value error_log /path/to/php.log
此外,您可能还需要检查web服务器的错误日志和邮件日志。检查电子邮件和筛选\u清理\u特殊\u字符不是清理特殊字符@--第二步检查您是否可以使用静态电子邮件id收到任何电子邮件意味着您的服务器是否配置为使用脚本发送电子邮件?是
邮件ng True?您是否配置了邮件服务器?