1

我是来自西澳大利亚珀斯的Fijura Web Design的 Beau。

我的服务器有问题。我正在尝试创建一个脚本,该脚本将发送带有附件的电子邮件,每当我尝试运行该脚本时,我都会收到以下响应:

警告: mail() [function.mail]:SMTP 服务器响应:552 5.7.0 DATA 标头大小超过第52E:\folder\folder\_api\sendreports.php中允许的最大值

我使用的代码是一个经过验证的脚本,因为我在数据中心的共享 Linux 服务器上使用它,但我无法让它在我的 Windows 服务器上运行。我使用的脚本是:

    include "../reports/rankings.php"; //this is my FPDF attachment
    $to=$array['email']; //this pulls an email address from an array output by my MySQL Server
    $from="Fijura SEO<seo@fijura.com.au>";
    $subject="SEO Ranking Report - New Data ".date("d M Y");
    $message="New SEO data is available. See attached report.";

// a random hash will be necessary to send mixed content
    $separator = md5(time());

// carriage return type (we use a PHP end of line constant)
    $eol = PHP_EOL;

// attachment name
    $filename = "SEO-Ranking-Report-".date("d-M-Y").".pdf";

// encode data (puts attachment in proper format)
    $pdfdoc = $pdf->Output("", "S");
    $attachment = chunk_split(base64_encode($pdfdoc));

// main header (multipart mandatory)
    $headers  = "From: ".$from.$eol;
    $headers .= "MIME-Version: 1.0".$eol; //If I remove all $header information from this line down the email sends fine, just without the attachment.
    $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; 
    $headers .= "Content-Transfer-Encoding: 7bit".$eol;
    $headers .= "This is a MIME encoded message.".$eol.$eol;

// message
    $headers .= "--".$separator.$eol;
    $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
    $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
    $headers .= $message.$eol.$eol;

// attachment
    $headers .= "--".$separator.$eol;
    $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
    $headers .= "Content-Transfer-Encoding: base64".$eol;
    $headers .= "Content-Disposition: attachment".$eol.$eol;
    $headers .= $attachment.$eol.$eol;
    $headers .= "--".$separator."--";

// send message
    mail($to,$subject,$message,$headers) or die("Failed");

随附的 PDF 应如下所示:示例 SEO 排名报告

php.ini 文件也配置如下:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail.bigpond.com
; http://php.net/smtp-port
smtp_port = 25
4

1 回答 1

0

I guess your email will be come back.I have 3 recommendation: 1. Read careful The Spamhaus Project that it cause your emails aren't spam. 2. create an *.eml and send it via socket. your .eml contain of your email such as type of header,body, attachment and etc. 3. don't use mail() function of php language, because some of shared hosting ban it.

于 2012-07-21T05:24:00.673 回答