Search code examples
phpimap

PHP imap_search() BODY vs TEXT


Does anyone know the difference between BODY and TEXT criteria in imap_search() ?

Description on php.net is very foggy and unclear

BODY "string" - match messages with "string" in the body of the message

TEXT "string" - match messages with text "string"

I've been testing both criteria and found no difference. Both looking for string in whole message.

The worst part (for me) is that both criteria looking for string also in message attachments. So if I have mails with 5mb *.csv files, imap_search() takes a lot of precious time.

I understand that BODY criteria should include attachments, because attachments are part of body. But using TEXT criteria I was expecting something different.


Solution

  • TEXT refers to anywhere in the e-mail: headers or body. BODY refers to body, including attachments.