我可以理解标签,我也成功编辑了一个名为GetSimple的CMS,一切正常(几个月前)。现在,几个月后我开始这样做了,不能通过......
我得到了成功发送的按摩......“感谢您与我们联系。我们很快就会与您联系。”但我没有收到邮件。我尝试过来自互联网的不同HTML和PHP示例,但问题也是如此。
HTML
<form method="POST" action="send.php" class="left" enctype="text/plain">
<input type="hidden" name="form-name" value="contact" />
<fieldset>
<label for="your_name">YOUR NAME *</label><input type="text" id="your_name" name="your_name" class="required" /><br/>
<label for="your_email">YOUR email *</label><input type="text" id="your_email" name="your_email" class="required email" /><br/>
<label for="current_site">current site</label><input type="text" id="current_site" name="current_site" /><br/>
<label for="estimated_budget">estimated budget</label><input type="text" id="estimated_budget" name="estimated_budget" /><br/>
<label for="project_description">project description</label> <textarea id="project_description" name="project_description"></textarea><br/>
<!--<input type="submit" value="send" id="sendbutton"> -->
<button class="defaultButton small" id="quotebutton"><span class="buttonLabel">Send</span></button>
</fieldset>
</form>
PHP命名为“send.php”
<?php
if(isset($_POST['email'])) {
$email_to = "mymail@gmail.com";
$email_subject = "example subject";
$your_name = $_POST['your_name']; // required
$your_email = $_POST['your_email']; // required
$error_message = "Please enter valid e-mail adress";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($your_name)."\n";
$email_message .= "Mail: ".clean_string($your_email)."\n";
$email_message .= "Current site: ".clean_string($current_site)."\n";
$email_message .= "Estimated budget: ".clean_string($estimated_budget)."\n";
$email_message .= "Project description: ".clean_string($project_description)."\n";
// create email headers
$headers = 'From: '.$your_email."\r\n".
'Reply-To: '.$your_email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
}
<!-- place your own success html below -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
die();
?>
答案 0 :(得分:2)
根据您的脚本,提交按钮需要包含名称值'email'
<input type="submit" value="send" id="sendbutton">
所以修复是:
<input type="submit" value="send" name="email" id="sendbutton" />
从表单中删除html note标记。 完整的代码:
<form method="POST" action="send.php" class="left" enctype="text/plain">
<input type="hidden" name="form-name" value="contact" />
<fieldset>
<label for="your_name">YOUR NAME *</label><input type="text" id="your_name" name="your_name" class="required" /><br/>
<label for="your_email">YOUR email *</label><input type="text" id="your_email" name="your_email" class="required email" /><br/>
<label for="current_site">current site</label><input type="text" id="current_site" name="current_site" /><br/>
<label for="estimated_budget">estimated budget</label><input type="text" id="estimated_budget" name="estimated_budget" /><br/>
<label for="project_description">project description</label> <textarea id="project_description" name="project_description"></textarea><br/>
<input type="submit" name="email" value="send" id="sendbutton">
</fieldset>
答案 1 :(得分:2)
首先我认为你遗漏的一些标题会看那些
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
第二次检查调用邮件功能时是真还是假
if( mail($email_to, $email_subject, $email_message, $headers)!==true)
{
die('Fail to send');
}
die('Sucess');
}