0
經過多次試驗和錯誤,我終於得到了一個php聯繫表格,以我想要的方式工作,並將正確的信息發送到我的託管郵箱地址。除了日期之外,一切都顯得很好,它根本沒有出現(在我的收件箱中)。我已經聯繫了託管服務,但他們沒有回覆。我也去研究php手冊,但幾乎沒有關於Date atribute/header的信息。有誰知道如何解決這個問題?從沒有日期的聯繫表格發送郵件
這裏是我的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 = "[email protected]";
$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");
}}
?>
謝謝你的快速回復,我在我的代碼中添加了這兩行代碼,但它不起作用,我仍然收到郵件中的日期爲空白。我使用roundcube電子郵件帳戶作爲我的收件箱。你認爲這可能與此有關嗎?無論如何,這裏是我修改後的代碼:http://jsfiddle.net/Uen6z/ – Crani0
我不認爲你的網絡郵件客戶端應該重要,除非他們已經忘記實現日期標題看起來很牽強。您可以通過將$ email_to值更改爲其他電子郵件地址來輕鬆檢查。你可以粘貼電子郵件的PHP數據(只是打印屏幕和複製/粘貼)以及收到的電子郵件原始數據的地方,並張貼鏈接到兩個? – SimpleAnecdote
不幸的是,我沒有其他的域名電子郵件地址,我不能讓它工作到我的Gmail或Hotmail。我確實設法在消息本身上正確地獲取日期和時間,但標題日期仍然是空白的。這裏是我的新的PHP代碼:http://jsfiddle.net/kCfSM/,這裏是我的電子郵件收到的打印屏幕:http://www.mediafire.com/view/febzimuuna1n532/php_mail_test.jpg# 抱歉問,但你的意思是通過電子郵件的原始數據?謝謝 – Crani0