php - Gmails 将 PHP 表单电子邮件标记为网络钓鱼
问题描述
我的网站上有一个“联系我”表单,它会将通过它提交的所有邮件发送到我的个人 Gmail 帐户。
出于某种原因,Gmail 会自动将大部分邮件发送到垃圾邮件文件夹,并将其标记为网络钓鱼。
我试图阅读这个问题,并重写我的代码,但我找不到解决方案。
没有人知道为什么吗?
这是我更新的PHP
表单代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Always force latest IE rendering engine -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Mobile Specific Meta -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- TITLE -->
<title>Thank You :)</title>
<!-- BOOTSTRAP CSS -->
<link rel="stylesheet" href="../css/bootstrap/bootstrap.min.css">
<!-- FONT-AWESOME CSS -->
<link rel="stylesheet" href="../css/font-awesome/css/font-awesome.min.css">
<!-- MAIN STYLE CSS -->
<link rel="stylesheet" href="../css/style.css">
<!-- RESPONSIVE CSS -->
<link rel="stylesheet" href="../css/responsive.css">
</head>
<body class="contact-p">
<?php
$TO = 'myemail@gmail.com';
//message the subject of the email
$SUBJECT = 'You've received a new message';
$MSG_SEND_ERROR = 'Couldn't send the message. Please try again';
// Sender Info
$name = $_POST['name'];
$email = $_POST['email'];
$subject = 'General subject';
$message = $_POST['message'];
$error = "";
// Email regex
$pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$^";
// test for name
if (empty($name)) {
$error .= 'error-name,'; // No name
}
// test for email
if (empty($email) || !preg_match_all($pattern, $email)) {
$error .= 'error-email,'; // No Email
}
// test for message
if (empty($message)) {
$error .= 'error-message'; // No Message
}
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: " . $name . " - " . $subject . " <" . $email . ">\r\nReply-To: " . $email . "";
if (!$error) {
//send the email
$send = mail($TO, $SUBJECT, $message, $headers);
if ($send) {
?>
<div class="contact-f contact-success col-md-6">
<i class="fa fa-smile-o fa-4x"></i>
<h3>Message sent :)</h3>
</div>
<?php
} else {
// If the message is not send return error
?>
<div class="contact-f contact-nosuccess col-md-6">
<i class="fa fa-frown-o fa-4x"></i>
<h3>Please fill the form</h3>
</div>
<?php
}
} else {
?>
<div class="contact-f contact-nosuccess col-md-6">
<i class="fa fa-frown-o fa-4x"></i>
<h3>Please fill the form and try again</h3>
</div>
<?php
}
?>
<!-- ====== JS ====== -->
<!-- JQUERY -->
<script type="text/javascript" src="../js/jquery.v1.12.4.js"></script>
<!-- BOOTSTRAP JS -->
<script src="../js/bootstrap.min.js"></script>
<!-- custom js -->
<script src="../js/main.js"></script>
</body>
</html>