我的页面上有一个表单,我提交的信息会在我的Hotmail电子邮件中继续访问我的垃圾文件夹。
我不知道该怎么办我不断更改标题,但邮件仍然会进入我的垃圾文件夹。
PHP的代码是:
<?php
$boundary = uniqid('np');
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'user@hotmail.co.uk';
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "X-Mailer: PHP's mail() Function\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
$headers .= "Subject: Contact\r\n";
$message = "This is a MIME encoded message.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
$message .= "This is the text/plain version.";
$message .= "\r\n\r\n--" . $boundary . "\r\n";
$message .= "Content-type: text/html;charset=utf-8\r\n\r\n";
$message .= "This is the <b>text/html</b> version.";
$message .= "\r\n\r\n--" . $boundary . "--";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. I will contact you shortly.');
window.location = 'http://www.user.com';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to user@hotmail.co.uk');
window.location = 'url';
</script>
<?php
}
?>
答案 0 :(得分:1)
一个可能的问题是,您发送电子邮件的smtp服务器是否与“来自”电子邮件不匹配。
例如,如果您使用“yourmail@gmail.com”填写from字段并且smtp服务器不是gmail的,则某些邮件提供商可能会将其标记为垃圾邮件。不幸的是,除了从你自己的域发送电子邮件,然后解析为你的smtp服务器,你无能为力。