这是我的php:
<?php
if(isset($_POST['email'])) {
foreach( $_POST as $value ){
if( stripos($value,'Content-Type:') !== FALSE ){
echo "There seems to be something wrong with your information. Please try again.";
exit;
}
}
if ($_POST["morada"] != "") {
echo "Oops! Error. Please try again.";
exit;
}
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "main@myemailaccount.com";
$email_subject = "Contact Form";
// validation expected data exists
if(!isset($_POST['nome']) ||
!isset($_POST['email']) ||
!isset($_POST['phone']) ||
!isset($_POST['website']) ||
!isset($_POST['motivo']) ||
!isset($_POST['mensagem'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$nome = $_POST['nome']; // required
$email = $_POST['email']; // required
$phone = $_POST['phone']; // required
$website = $_POST['website']; // not required
$motivo = $_POST['motivo']; // required
$mensagem = $_POST['mensagem']; // required
$error_message = "";
$email_message = "Form details below.<br><br>";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Nome: ".clean_string($nome)."<br>";
$email_message .= "Email: ".clean_string($email)."<br>";
$email_message .= "Telefone: ".clean_string($phone)."<br>";
$email_message .= "Website: ".clean_string($website)."<br>";
$email_message .= "Motivo: ".clean_string($motivo)."<br>";
$email_message .= "Mensagem: ".clean_string($mensagem)."<br><br><br><br>";
$email_message = wordwrap($email_message, 70);
// create email headers
$headers = "";
$headers .= 'From: '.$nome.'<'.$email.'>'.$eol;
$headers .= 'Reply-To: '.$nome.'<'.$email.'>'.$eol;
$headers .= 'Return-Path: '.$nome.'<'.$email.'>'.$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-type: text/html; charset=utf-8".$eol;
@mail($email_to, $email_subject, $email_message, $headers);
{
echo header("Location: thanks.html");
}}
?>
答案 0 :(得分:1)
没有配置邮件引擎的服务器,所以我无法对其进行测试。但我认为你只需要添加&#39;日期&#39;头:
$headers .= 'Date: '.date('r').$eol;
您可能需要配置默认时区:
date_default_timezone_set("UTC");
http://il1.php.net/manual/en/function.date-default-timezone-set.php