邮件gt被gmail标记为垃圾邮件,任何解决方案?

时间:2013-11-05 06:35:45

标签: php email gmail spam

我正在使用php代码在我的网络应用程序中发送带附件的邮件。一切正常,期待gmail将其标记为垃圾邮件。我的代码如下所示。

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!";
        }

请帮帮我

1 个答案:

答案 0 :(得分:0)

创建最完美的邮件并不完全知道mail()函数。垃圾邮件过滤器对邮件标题非常挑剔,自己构建它们并不是一件容易的事。更好地使用smtp库来创建包含所有重要标题(如phpmailer)的邮件消息

还要确保您发送邮件的服务器具有良好的IP信誉和正确的邮件设置(HELO /反向DNS等)