带有PDF附件标题的php邮件导致只进入邮件

时间:2012-10-06 02:39:00

标签: email pdf header php

我有一个生成PDF格式的网络表单,在提交时会通过电子邮件发送给我,但电子邮件会一直过滤到垃圾邮件中的文件夹。我怀疑电子邮件标题中的内容有问题,但不确定它可能是什么。

感谢任何帮助。

以下是摘录......

// send by email
    $fileatt = '../pdfs/'.$filename;
    $fileatt_type = mime_content_type_manual($fileatt); // File Type  "application/pdf"
    $fileatt_name = $filename; // Filename that will be used for the file as the attachment 

    $email_from = "auth@mysite.com"; // Who the email is from 
    $email_subject = "Auth Report"; // The Subject of the email 

    //$email_to = "info@mysite.com";
    $email_to = "info@mysite.com";

    $headers = "From: ".$email_from; 

    $file = fopen($fileatt,'rb'); 
    $data = fread($file,filesize($fileatt)); 
    fclose($file); 

    $semi_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 

    $headers .= "\nMIME-Version: 1.0\n" . 
    "Content-Type: multipart/mixed;\n" . 
    " boundary=\"{$mime_boundary}\""; 

    $email_message .= "This is a multi-part message in MIME format.\n\n" . 
    "--{$mime_boundary}\n" . 
    "Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
    "Content-Transfer-Encoding: 7bit\n\n" . 
    $email_message .= "\n\n"; 

    $data = chunk_split(base64_encode($data)); 

    $email_message .= "--{$mime_boundary}\n" . 
    "Content-Type: {$fileatt_type};\n" . 
    " name=\"{$fileatt_name}\"\n" . 
    "Content-Transfer-Encoding: base64\n\n" . 
    $data .= "\n\n" . 
    "--{$mime_boundary}--\n";

1 个答案:

答案 0 :(得分:0)

如果您为自己的案例添加电子邮件的发件人 auth@mysite.com ,则将其作为电子邮件客户端地址簿的新联系人添加,然后,电子邮件可能不会被标记为垃圾邮件,因为它来自您的联系地址簿成员。