1

西オーストラリア州パースにあるFijura Web DesignのBeau です。

サーバーに問題があります。添付ファイル付きの電子メールを送信するスクリプトを作成しようとしていますが、スクリプトを実行しようとすると、次の応答が返されます。

警告: mail() [function.mail]: SMTP サーバーの応答: 552 5.7.0 DATA ヘッダー サイズがE:\folder\folder\_api\sendreports.php52で許可されている最大サイズを超えています

私が使用しているコードは、データ センターの共有 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

あなたのメールは戻ってくると思います。3 つ推奨事項があります。2. *.eml を作成し、ソケット経由で送信します。.eml には、ヘッダーの種類、本文、添付ファイルなどの電子メールが含まれています。 3. 一部の共有ホスティングでは禁止されているため、php 言語の mail() 関数を使用しないでください。

于 2012-07-21T05:24:00.673 に答える