在 PHP 中获取 IMAP 标头
嘿伙计们, 我对 PHP 的 imap 函数完全感到困惑,它们到处都是,我已经通过注释挖掘了这么多。我可以执行 imap_fetchbody($connection, 5, null); 并检索整个消息,它为我提供了我需要的一切:
即:
收件人:[电子邮件受保护] 内容类型: 多部分/混合; 边界=001517570c8a681a5004a36a1fd6
--001517570c8a681a5004a36a1fd6 内容类型:多部分/替代; 边界=001517570c8a681a4804a36a1fd4
--001517570c8a681a4804a36a1fd4 内容类型:文本/纯文本; 字符集=ISO-8859-1
asdf
--001517570c8a681a4804a36a1fd4 内容类型:text/html; 字符集=ISO-8859-1
asdf
--001517570c8a681a4804a36a1fd4-- --001517570c8a681a5004a36a1fd6 内容类型:图像/gif; 名称=“ajax-loader.gif” 内容处置:附件; 文件名=“ajax-loader.gif” 内容传输编码:base64 X-附件-Id:f_gnruant80
...这里省略了一堆代码...
但我真的希望在数组或对象中使用这些信息。 无需想出一些正则表达式来从上面的整个文本中获取数据。
有谁知道如何做到这一点或使用哪个 php imap 命令?或者是否有一个地方有任何人都知道的非常好的例子?
Hey Guys,
I am totally confused on PHP's imap functions, they are all over the place and I've dug through comments to get this far. I can do imap_fetchbody($connection, 5, null); and retrieve the entire message which gives me all that i need:
ie:
To: [email protected] Content-Type:
multipart/mixed;
boundary=001517570c8a681a5004a36a1fd6--001517570c8a681a5004a36a1fd6 Content-Type: multipart/alternative;
boundary=001517570c8a681a4804a36a1fd4--001517570c8a681a4804a36a1fd4 Content-Type: text/plain;
charset=ISO-8859-1asdf
--001517570c8a681a4804a36a1fd4 Content-Type: text/html;
charset=ISO-8859-1asdf
--001517570c8a681a4804a36a1fd4--
--001517570c8a681a5004a36a1fd6 Content-Type: image/gif;
name="ajax-loader.gif"
Content-Disposition: attachment;
filename="ajax-loader.gif"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gnruant80... bunch of code here omitted ...
But I really want this information in an Array or Object to use it. without having to think up some regular expression to get data out of the entire texts above.
Does anyone know a way to do that or which php imap command to use? Or is there a place with really good examples anyone knows of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以对
section
参数(第三个参数)使用非空值。请参阅 http://php.net/manual/en/function 的第二个示例。 imap-fetchbody.php。我想这就是你正在寻找的。You can use a non null value for
section
parameter(3rd parameter). Please see second example of http://php.net/manual/en/function.imap-fetchbody.php. I think that is what you are searching.