Here is a strange one for you.
I am using the Ipipi SMS
to email service to send control commands to a PHP
script.
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;
If I send a sms message to the mailbox imap_fetchbody
, it returns empty.
However, if I then read the mailbox with a email client the message is there. I do not think it is an Ipipi
issue.
If I do a var_dump($message)
I get string(0) ""
.
When you issue
$message = imap_fetchbody($inbox,$email_number,2);
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 ] )
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With