我正在尝试将表单提交到电子邮件,最终以 gmail 地址结束。但是,我收到返回错误说:
Our_system_has_detected_that_this_message_is/550-5.7.1_not_RFC_2822_compliant._To_reduce_the_amount_of_spam_sent_to_Gmail,/550-5.7.1_this_message_has_been_blocked._Please_review/550_5.7.1_RFC_2822_specifications_for_more_information。w10si875474obo.147 -_gsmtp/
下面的代码,我做错了什么还是我在某处遗漏了错误的代码/语法?:
<?php
if($_POST) {
if($_POST["token"]==true){
$email = $_POST['email'];
$from_name = 'Whoever';
$from = 'someemail@whatever.com';
$to = 'someemail@gmail.com';
$subject = 'Connect Form';
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "Date: ". date("r") ."\r\n". "From: ".$from . "\r\nFrom: ".$from_name." <".$from.">\r\n";
$headers .= "MIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message_top = "This is a multi-part message in MIME format.\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n";
if(sizeof($_POST['contact_via'])>0)
$contact_via=implode(", ", $_POST['contact_via']);
else
$contact_via="";
$email_message = "\n".'<table cellspacing="4">
<tr><td align="right">Contact Name : </td><td>'.$_POST['contact_name'].'</td></tr>
</table>';
$email_message = stripslashes($email_message);
$email_message = str_replace("\n","\n",$email_message);
$email_message = $message_top . $email_message;
mail($to, $subject, $email_message, $headers);
echo '<script>window.location = "http://www.website.com/Thank-You.html";</script>';
exit;
}else{
echo '<script>window.location = "http://www.website.com/Thank-You.html";</script>';
exit;
}
}
?>