第一次发帖。我确实阅读了有关此问题的网站,但我没有找到答案或没有意识到我找到了答案。我在网站上放置了一个简单的 PHP 电子邮件注册框。这是我的代码:
enter code here
function spamcheck($field)
{
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
$recipient = "mymail@mydomain.com";
$subject = "Email subscription list";
$sender = $recipient;
$subscription = $_REQUEST['subscription'];
if (isset($_REQUEST['emaillist']))
$mailcheck = spamcheck($_REQUEST['emaillist']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
}
else
{
$body .= "Email: ".$_REQUEST['emaillist']." \n";
$body .= "Subscribe: ".$_REQUEST['subscription']." \n";
if ($subscription == "subscribe")
{$location = "thankyou.html";}
else {$location = "thankyou2.html";};
mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");
header( "Location: $location" ); } ?>
这些电子邮件使用我的 gmail 或网站域上的电子邮件进入垃圾邮件文件夹。我认为这是因为主题和收件人相同,但这可能只是告诉我们的网站主机允许这些邮件通过。感谢您提供任何帮助/建议,并提前感谢您。