我试图弄清楚为什么这个表单在提交后没有通过电子邮件发送。我做了一个测试,PHP邮件在服务器上正常工作。标题可能有问题吗?
提前感谢任何建议!
<?php
if(!empty($_POST['first-name'])) {
$_POST['email'] = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$agree1 = implode(", ", $_POST['certify-info-true']);
$agree2 = implode(", ", $_POST['understand-false-info']);
$agree3 = implode(", ", $_POST['final-sig']);
foreach($_POST as $name => $value) {
$value = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
if($name == 'submit') {
//skip
}
elseif ($name == 'certify-info-true') {
$res .= "$name : $agree1 \n \n";
}
elseif ($name == 'understand-false-info') {
$res .= "$name : $agree2 \n \n";
}
elseif ($name == 'final-sig') {
$res .= "$name : $agree3 \n \n";
}
else {
$res .= "$name : $value \n \n";
}
}
//SET here the destination email address and subject line
mail('test@testmail.com','Application', "$res", "From: {$_POST['email']}");
//SET here the thank you message
echo "<h2>Thank you.</h2>";
//print_r($_POST);
} else {
?>
<form action="" id="test" method="POST"></form>
<? } ?>