目前我正在直接从输入流中读取邮件,然后对其进行一些操作,然后我需要发送修改后的邮件。
我已经成功阅读并修改了邮件,现在可以将邮件作为原始邮件转发给用户了。
因此,为此我使用了邮件功能,但此邮件功能以原始格式发送消息,因为我正在阅读邮件并在正文中设置变量。如何将其作为看起来像格式的原始邮件(原始格式转换为实际邮件?)
#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd))
{
$email .= fread($fd, 1024);
}
fclose($fd);
mail('you@yoursite.com','subject of the mail','"' . $email . '"'); // problem
?>
输出:
Return-Path: <user1@abc.com>
Received: from abc.abc.com
by abc.abc.com with ESMTP id r8CHQuwsvl019623
for <abc@abc.com>; Thu, 12 Sep 2013 10:26:56 -0700
Received: from abc@abc.com ([xx.xx.xx.xx]) by abc@abc.com ([xx.xx.xx.xx]) Thu, 12 Sep 2013 10:26:55 -0700
From: <user1@abc.com>
To: <user2@abc.com>
Subject: Here is the subject
Thread-Topic: ACTION REQUIRED: Here is the subject
Thread-Index: Ac6vLqD991sdflXReXHStipZDdjUh0dpgAoQZUQAANQNRA=
Date: Thu, 12 Sep 2013 17:26:55 +0000
Message-ID: <A61C9CD725DF1C4FA94C13E9C8BEE9C538A35785@az18ex3004.abc.com>
References: <53B09D5B548AF94EB5B6C48321C34F2E11CB1621@az18ex3006.abc.com>
In-Reply-To: <53B09D5B548AF93e4EB5B6C48321C34F2E11CB1621@az18ex3006.abc.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
x-originating-ip: [xx.xx.xx.xx]
Content-Transfer-Encoding: base64
MIME-Version: 1.0
asdfxGSIb3DQEHAqCAMIACAQsdfsdAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAaCAJIAEgge4Q29u
dGVudC1UeXBlOiBtdWx0aXBhcnQvYWx0ZXJuYXRpdmU7DQoJYm91bmRhcnk9Ii0tLS09X05leHRQ
YXJ0XzAwMF8wMDkxXzAxQ0VBRkEyLjk5RTBFQUEwIg0KDQpUaGlzIGlzIGEgbsdfsdGlwYXJ0IG1l
c3NhZ2UgaW4gTUlNRSBmb3JtYXQuDQoNeddi0tLS0tLT1fTmV4dFBhcnRfMDAwXzAwOTFfMDFDRUFG
QTIuOTlFMEVBQTANCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsNCgljaGFyc2V0PSJ1cy1hc2Np