[英]PHP email processor not working
我有一些代碼是基本的電子郵件表單。 它不起作用。 我知道我的表格有效,因為它是我為其他人制作的表格的美化版本。
可能是太晚了,我忽略了一些東西。
<?php
$subject = 'Contact Form ';
$subject .= $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$comments = strip_tags($_POST['comments']);
$url = $_POST['url'];
$to = 'someemail@email.com';
$headers = "From: ".$name." <".$email.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $comments, $headers);
?>
當然,在我讓它工作后,我會采取一些反垃圾郵件措施。 我什至嘗試過輸出變量的內容。 它似乎與 $_POST 有某種關系。
編輯:顯然我的主機默認使用 php4,我在 .htaccess 中使用了“AddHandler x-mapp-php5 .php”來強制 php5,它解決了我所有的問題。 :)
代碼似乎沒問題。 嘗試調試郵件結果:
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
$result = mail($to, $subject, $comments, $headers);
var_dump($result);
猜猜您的 smtp 設置錯誤或根本沒有配置。
請檢查您的 php.ini http://www.php.net//manual/en/mail.configuration.php
http://www.w3schools.com/php/php_ref_mail.asp
我認為,您的服務器中禁用了郵件功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.