我创建了一个网站并将其上传到免费托管网站来测试php。当我从网站发送测试电子邮件并将接收地址设置为我的Gmail电子邮件帐户时,我会收到它们。但是,它们被标记为垃圾邮件/网络钓鱼(在电子邮件中我有一个红色警告标签)。但是,当我将接收地址设置为我客户的Gmail帐户时,他根本没有得到它们,他们没有出现在他的垃圾邮件箱中(他让我看看他的垃圾邮件帐户到确认)。
我想他可能有一个我的电子邮件没有的spamblocker级别?或者是因为我使用免费托管网站发送电子邮件而发生这种情况?我计划将它上传到GoDaddy。您认为将其上传到付费托管网站会改变我的情况还是需要PHPMailer?我的问题是为什么我收到电子邮件,但是当我将接收邮件切换到我的客户时,他根本没有收到这些邮件?
这是我的php代码:
<?php
if(isset($_POST['email-ad'])) {
$email_to = "xxxxxxx1@gmail.com"; //my email
$email_subject = "General Inquiry from xxxxcompany";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email-ad']) ||
!isset($_POST['phone']) ||
!isset($_POST['intention']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email-ad']; // required
$telephone = $_POST['phone']; // required
$intention = $_POST['intention']; // not required
$comments = $_POST['comments']; // not required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The name that you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Phone: ".clean_string($telephone)."\n";
$email_message .= "Intention: ".clean_string($intention)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
sleep(2);
echo "<meta http-equiv='refresh' content=\"5; url=index.html\">";
?>
<html>
<head>
<link rel="stylesheet" href="css/style.css">
</head>
<body bgcolor="black">
<font color="white">
<font family="Helvetica">
<div class="redirect">Thank you for contacting us. We will be in touch with you very soon. You will redirected back to the homepage in a few. </div>
</font>
</font>
</body>
</html>
<?php
}
?>
答案 0 :(得分:0)
由于使用免费托管服务,最有可能发生这种情况。请记住,由于其性质,它更有可能在共享Web主机上拥有垃圾邮件发送者:许多用户使用相同的IP地址发送邮件。此外,由于它是一个免费托管服务,每个人都可以发送电子邮件,因此也发送垃圾邮件。
顺便说一句,就像你说的那样,一些电子邮件提供商使用相当激进的垃圾邮件拦截功能,这可能是你的客户根本没有收到你的电子邮件的原因。