form action再次被鏈接到這個PHP腳本:麻煩網友ip
<?php
$email = $_POST['subscribefield'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Dit adres klopt niet";
die();
}
$to = "[email protected]";
$subject = "Abonee voor de nieuwsbrief";
$body = "$email \n Heeft zich aangemeld voor de nieuwsbrief";
mail($to, $subject, $body);
echo "U bent succesvol aangemeld voor de Vandenberg nieuwsbrief";
echo $_SERVER['REMOTE_ADDR'];
?>
在我加入echo $_SERVER['REMOTE_ADDR'];
然後我檢查我的郵件,但沒有什麼結束。我以錯誤的方式使用代碼嗎?
編輯:
<?php
$email = $_POST['subscribefield'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Dit adres klopt niet";
die();
}
$to = "[email protected]";
$subject = "Abonee voor de nieuwsbrief";
$body = "$email \n Heeft zich aangemeld voor de nieuwsbrief";
$body .= $_SERVER['REMOTE_ADDR'];
mail($to, $subject, $body);
echo "U bent succesvol aangemeld voor de Vandenberg nieuwsbrief";
?>
以上是編輯^
'$ body'是電子郵件的內容。 – chris85
它可能被標記爲垃圾郵件,因爲您錯過了標題。閱讀http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-email - 此外,你是否在本地或服務器上運行這個?如果郵件被髮送,但你看不到IP,這是因爲IP沒有被添加到'$ body'變量中,所以它不會與郵件一起發送。請參閱['mail()'](http://php.net/manual/en/function.mail.php)文檔 – Qirel
哦,我收到了郵件,但它沒有顯示ip @Qirel – Kevin