質問

以下の$ヘッダーは、PHPのmail($to,$subject,$content,$header)コマンドを経由して送信されています。メールが到着し、添付ファイルを持っているように見えます。ファイルがあるとしてではなく、メール本文は空です。私は、これは行間隔とは何かを持っていると思うが、私は問題を見ることができません。私はそれが$contentsに追加するのではなく、$headerに(境界の間)の内容を入れて試してみました。それは違いはありません。任意の考え?

From: dnagirl@someplace.com 
Reply-To: dnagirl@someplace.com 
X-Mailer: PHP 5.3.1
MIME-Version: 1.0
Content-Type: multipart/mixed;
    boundary="7425195ade9d89bc7492cf520bf9f33a"

--7425195ade9d89bc7492cf520bf9f33a
Content-type:text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

this is a test message.

--7425195ade9d89bc7492cf520bf9f33a
Content-Type: application/pdf; name="test.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.pdf"

JVBERi0xLjMKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIFIvRmlsdGVyIC9GbGF0ZURlY29k
ZT4+CnN0cmVhbQp4nE2PT0vEMBDFadVdO4p/v8AcUyFjMmma5CqIIF5cctt6WnFBqLD1+4Np1nY3
c3lvfm+GyQ4VaUY11iQ2PTyuHG5/Ibdx9fIvhi3swJMZX24c602PTzENegwUbNAO4xcoCsG5xuWE
.
... the rest of the file
.
MDAwMDA2MDYgMDAwMDAgbiAKMDAwMDAwMDcwNyAwMDAwMCBuIAowMDAwMDAxMDY4IDAwMDAwIG4g
CjAwMDAwMDA2NDcgMDAwMDAgbiAKMDAwMDAwMDY3NyAwMDAwMCBuIAowMDAwMDAxMjg2IDAwMDAw
IG4gCjAwMDAwMDA5MzIgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSAxNCAvUm9vdCAxIDAgUiAv
SW5mbyAyIDAgUgovSUQgWzxEMURDN0E2OUUzN0QzNjI1MDUyMEFFMjU0MTMxNTQwQz48RDFEQzdB
NjlFMzdEMzYyNTA1MjBBRTI1NDEzMTU0MEM+XQo+PgpzdGFydHhyZWYKNDY5MwolJUVPRgo=


--7425195ade9d89bc7492cf520bf9f33a--

$headerは、改行せずに終了

役に立ちましたか?

解決

Iは添付並びにHTMLおよびテキストメッセージ部でメッセージを送信するために以下のコードを使用します。私はそれを右にそれを得るために長い時間を戦った覚えが、残念ながら私の問題があった部分は覚えていません。多分それを見てすることはあなたを助けます。私はいくつかの無関係な変数を変更し、うまくいけば読みすることが容易になりました。何かが奇妙か不明である場合はお気軽にと私が説明しようとするでしょう。

public function sendEmail($htmlString)
{
    $random_hash = md5(date('r', time()));

    $message = "--mixed-$random_hash\n";
    $message .= 'Content-Type: multipart/alternative; boundary="alt-' . $random_hash . '"' . "\n\n";
    $message .= 'MIME-Version: 1.0' . "\n";
    $message .= '--alt-' . $random_hash . "\n";
    $message .= 'Content-Type: text/plain; charset="iso-8859-1"' . "\n";
    $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n";

    // text message
    $message .= strip_tags($htmlString) . "\n\n";

    $message .= '--alt-' . $random_hash . "\n";
    $message .= 'Content-Type: text/html; charset="iso-8859-1"' . "\n";
    $message .= 'Content-Transfer-Encoding: 7bit' . "\n\n";

    // html message
    $message .= $htmlString . "\n\n";

    $message .= '--alt-' . $random_hash . '--' . "\n";

    // graph image
    if($this->selectedGraph != 0)
    {
        $graphString = $this->getGraph(); // image attachment
        $graphString = chunk_split(base64_encode($graphString));

        $linkID = 'graph-' . $userInfo['FirmID'] . $random_hash . '-image';

        $message .= '--mixed-' . $random_hash . "\n";
        $message .= 'MIME-Version: 1.0' . "\n";
        $message .= 'Content-Transfer-Encoding: base64' . "\n";
        $message .= 'Content-ID: ' . $linkID . "\n";
        $message .= 'Content-Type: image/gif; name="graph.gif"' . "\n";
        $message .= 'Content-Disposition: attachment' . "\n\n";

        $message .= $graphString;
        $message .= '--mixed-' . $random_hash . '--' . "\n";

    }
    else
    {
        $message .= '--mixed-' . $random_hash . '--' . "\n";
    }


    $headers = 'From: ' . $this->from. "\r\nReply-To: " . $this->replyto;
    $headers .= "\r\nContent-Type: multipart/related; boundary=\"mixed-" . $random_hash . "\"\r\nMIME-Version: 1.0";

    $flags = '-f ' . BOUNCED_EMAIL_ADDRESS;

    return mail($userInfo['Email'], $this->subject, $message, $headers, $flags);

}

他のヒント

最初からMIMEメールを構築する際に

これらのことが起こります。あなたはクールと互換性のあるMIMEメッセージを生成するために使用できるPHPモジュールがいくつかあります。 Mail_Mime のトリックを行う必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top