[英]mail gt marked as spam by gmail, any solutions?
i am using php code to send a mail with an attachment in my web application. 我正在使用php代码在我的Web应用程序中发送带有附件的邮件。 all are working fine expect gmail marked it as spam. 一切正常,期望gmail将其标记为垃圾邮件。 my code is look like below. 我的代码如下所示。
move_uploaded_file($_FILES["file"]["tmp_name"],$path . $_FILES["file"]["name"]);
$filename = $_FILES["file"]["name"];
//$path = "upload/";
$from_name = $_POST['name'];
$from_mail = $_POST['email'];
$mailto = $replyto = "nevinthomas153@gmail.com";
$subject = "Resume";
$message = $_POST['msg'];
$to = "nevinthomas153@gmail.com";
$file = $path.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";
if (mail($mailto, $subject, "", $header)) {
echo "mail send ... OK"; // or use booleans here
} else {
echo "mail send ... ERROR!";
}
Please help me 请帮我
the mail() function isn't exactly known to create the most perfect mails . 不能确切地知道mail()函数可以创建最完美的邮件。 Spam filters are very picky about mail headers, it's no easy task to build them all correctly yourself. 垃圾邮件过滤器对邮件头非常挑剔,要自己正确地构建它们并非易事。 better use a smtp library that creates the mail messages with all important headers (like phpmailer ) 最好使用smtp库来创建具有所有重要标头的邮件(例如phpmailer)
also make sure the server you send the mails from has a good IP reputation and correct mail setup (HELO / reverse DNS etc) 还请确保您从中发送邮件的服务器具有良好的IP信誉,并且邮件设置正确(HELO /反向DNS等)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.