为什么我在使用php:// stdin时收到重复的正文内容邮件?

时间:2012-08-04 19:30:53

标签: php parsing email

我有一个后缀服务器将所有收件邮件重定向到php脚本

但邮件的正文内容显示重复,看起来:

--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?

为什么会出现两次邮件? (和html中的一个:S)

我怎么才能得到一个? 谢谢!

1 个答案:

答案 0 :(得分:2)

假设您的代码返回相同类型的分隔符,则可能需要执行以下操作:

// 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];