0

私はすべての着信メールをphpスクリプトにリダイレクトするpostfixサーバーを持っています

しかし、メールの本文の内容は重複しているように見えます。

--000e0ce03cf6d06b0c04c67595d4
Content-Type: text/plain; charset=ISO-8859-1

why
show
this
duplicated?

--000e0ce03cf6d06b0c04c67595d4
Content-Type: text/html; charset=ISO-8859-1

why<div>show</div><div>this</div><div>duplicated?</div>

--000e0ce03cf6d06b0c04c67595d4--

私はこの本文の内容でGmailを使用してこのメ​​ールを送信しました:

why
show
this
duplicated?

なぜメールが2回表示されるのですか?(そしてhtmlの1つ:S)

どうすれば1つだけ入手できますか?ありがとう!

4

1 に答える 1

2

コードが同じ種類のセパレーターを返すと仮定すると、1つの方法は次のようにすることです。

// Get separator
$mail_pieces = explode("\n", $mail);
$separator = $mail_pieces[0];

// Separate email
$mail_pieces = explode($separator, $mail);
$text_mail = $mail[0];
$html_mail = $mail[1];
于 2012-08-04T19:35:55.473 に答える