Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP imapèu fetchbody can';无法获取HTML标记链接url_Php_Email_Imap - Fatal编程技术网

PHP imapèu fetchbody can';无法获取HTML标记链接url

PHP imapèu fetchbody can';无法获取HTML标记链接url,php,email,imap,Php,Email,Imap,我正在构建一个电子邮件阅读脚本,它通过imap阅读电子邮件,当我尝试使用imap_fetchbody阅读电子邮件正文时,它只显示文本,但电子邮件正文有一个链接似乎不显示 这是我的密码 $hostname = '{mail.test.com/notls}INBOX'; $username = 'info@test.com'; $password = 'testopw'; /* try to connect */ $inbox = imap_open($ho

我正在构建一个电子邮件阅读脚本,它通过imap阅读电子邮件,当我尝试使用imap_fetchbody阅读电子邮件正文时,它只显示文本,但电子邮件正文有一个链接似乎不显示

这是我的密码

    $hostname = '{mail.test.com/notls}INBOX';
    $username = 'info@test.com';
    $password = 'testopw';

    /* try to connect */
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Email Server: ' . imap_last_error());
    /* grab emails */
    $emails = imap_search($inbox,'SEEN FROM "noreply@test.com"');
if($emails) {

    /* put the newest emails on top */
    rsort($emails);
    /* for every email... */
    foreach($emails as $email_number) {
        /* get information specific to this email */                
       echo $message = imap_fetchbody($inbox,$email_number,1);
}
}
电子邮件内容如下所示

 We do our utmost to arrive to you on time. There may, however, 
be unexpected circumstances, causing our driver to be delayed. 
You can follow the current status of your assignment here.
当我从邮件客户端阅读电子邮件时,text这里有一个链接,但当使用php阅读时,它只显示一个文本

电子邮件屏幕截图
有人知道这个问题的原因是什么,或者是否需要更改一些参数来获取带有url的链接。谢谢

您必须检查电子邮件的多个部分。您实际上可以阅读电子邮件的源代码。这很容易理解,您将识别不同的部分

imap_fetchbody($inbox,$email_number,$section);

您在评论中提到的部分是一个PNG文件。某些部分可以用base64编码,因为电子邮件是基于文本的协议

电子邮件示例:

 From: Nathaniel Borenstein <nsb@bellcore.com> 
 To:  Ned Freed <ned@innosoft.com> 
 Subject: Sample message 
 MIME-Version: 1.0 
 Content-type: multipart/mixed; boundary="simple 
 boundary" 

 This is the preamble.  It is to be ignored, though it 
 is a handy place for mail composers to include an 
 explanatory note to non-MIME compliant readers. 
 --simple boundary 

 This is implicitly typed plain ASCII text. 
 It does NOT end with a linebreak. 
 --simple boundary 
 Content-type: text/plain; charset=us-ascii 

 This is explicitly typed plain ASCII text. 
 It DOES end with a linebreak. 

 --simple boundary-- 
 This is the epilogue.  It is also to be ignored.
发件人:Nathaniel Borenstein
致:内德·弗里德
主题:示例消息
MIME版本:1.0
内容类型:多部分/混合;boundary=“简单
边界“
这是序言。这是可以忽略的,尽管它
是一个方便的地方,邮件编写者可以将
非MIME兼容读者的解释性说明。
--简单边界
这是隐式类型的纯ASCII文本。
它不会以换行符结束。
--简单边界
内容类型:文本/纯文本;字符集=美国ascii码
这是显式键入的纯ASCII文本。
它以换行符结束。
--简单边界--
这是结束语。这也是不容忽视的。

这是因为您正在从邮件中获取文本。在邮件中,文本和html是不同的部分,因此您需要首先获取结构,然后将其传递到fectchbosy中,然后从我使用的结果1.2中检索结果,但返回为空,当我使用2.2时,输出是这样的,我尝试了Vborw0KggoaaaAnsuhueugaabaaaaqcayaaaaf8/9hAAAB2ElEQVR4nH2Tz0sUYRjHP7qrbiBK OkWggeihpytertpueCpooldon+hQ7cudlXBq+TbgXp70IPKrDe9FuxQhGqBrakLoadRj3Vnx+/OzVzVzVzVzPzP93JU4Ok8SLMYWLV4YU8YUvJ89TkusqauvVfV5SvVfV5SVRpX54Iz1xHM6oaq7gyXhxeP+ZAJKQD6D0WODZQL6HLL0VSPI6GP/4N5w44e7lhGwzgQC8iqNf8CkZ RGvuQudLqG0Rfg5+PGBtunoagayZ0M7JP5J9VWOQDGGY2Y9HY0ADH/+jy+RZAFPgCqWy HHH72HBFCNIFZ5+CO6E4R5B7B7B7B7N7N7N7N4K+4B4PTXmH0B6B6B6B6B6B6B6B6B6B6B6B6B6B6N4K+B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B6B。可能是附件当我在电子邮件客户端上看到时没有附件,而且base64解码也显示有线输出你能给我发送输出吗?
 From: Nathaniel Borenstein <nsb@bellcore.com> 
 To:  Ned Freed <ned@innosoft.com> 
 Subject: Sample message 
 MIME-Version: 1.0 
 Content-type: multipart/mixed; boundary="simple 
 boundary" 

 This is the preamble.  It is to be ignored, though it 
 is a handy place for mail composers to include an 
 explanatory note to non-MIME compliant readers. 
 --simple boundary 

 This is implicitly typed plain ASCII text. 
 It does NOT end with a linebreak. 
 --simple boundary 
 Content-type: text/plain; charset=us-ascii 

 This is explicitly typed plain ASCII text. 
 It DOES end with a linebreak. 

 --simple boundary-- 
 This is the epilogue.  It is also to be ignored.