PHP5-IMAP“我没有身体!" [英] PHP5-IMAP 'I aint got no body!'

查看:63
本文介绍了PHP5-IMAP“我没有身体!"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对你来说很奇怪.

我正在使用Ipipi SMS通过电子邮件发送服务,以将控制命令发送到PHP脚本.

I am using the Ipipi SMS to email service to send control commands to a PHP script.

我可以将电子邮件发送到我的邮箱,然后使用此代码段中的PHP-IMAP命令阅读并显示它们:

I can send email messages to my mailbox, then read and display them using PHP-IMAP commands as in this code segment:

$overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); echo $message;

$overview = imap_fetch_overview($inbox,$email_number,0); $message = imap_fetchbody($inbox,$email_number,2); echo $message;

如果我向mailbox imap_fetchbody发送短信,则返回空白.

If I send a sms message to the mailbox imap_fetchbody, it returns empty.

但是,如果我随后通过电子邮件客户端阅读了邮箱,则消息在那里.我认为这不是Ipipi问题.

However, if I then read the mailbox with a email client the message is there. I do not think it is an Ipipi issue.

如果我执行var_dump($message),我会得到string(0) "".

If I do a var_dump($message) I get string(0) "".

推荐答案

发布时

$message = imap_fetchbody($inbox,$email_number,2);

您要询问消息第2部分的内容. (这就是imap_fetchbody第三个参数的含义.)

you're asking for the content of part 2 of the message. (That's what the third argument to imap_fetchbody means.)

string imap_fetchbody ( resource $imap_stream , int $msg_number ,
                        string $section [, int $options = 0 ] )

如果无法从SMS网关中看到示例消息,很难知道,但是我想您的消息不是多部分的,因此没有第2部分.如果替换为a,会发生什么情况?提取此特定消息时,1是否是2?

It's hard to know without being able to see a sample message from the SMS gateway, but I'd guess that your message isn't a multipart and thus it doesn't have a part 2. What happens if you substitute a 1 for the 2 when fetching this particular message?

(通常,在确定要提取的正文部分之前,您需要先查看消息结构.可以使用

(In general, you'll want to look at the message structure before deciding which body part to fetch. You can use imap_fetchstructure for this.)

这篇关于PHP5-IMAP“我没有身体!"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆