I am using the PHP IMAP libraray's imap_search()
function to search mails in a Gmail inbox via the subject string.
imap_seach($mbox, 'ALL SUBJECT "<search string>"');
This search returns perfectly fine for alphanumeric strings but fails when it has special characters like slash, comma, colon, single quote, hyphen, and many other characters that I do not even know of. Escaping them doesn't help. Replacing a few of them with space helps sometime but not in all cases.
Is there a standard way to filter the search string so that it never errors out and returns some result? I have tried tokenizing the subject sting and removing all words from the search string which even one alphanumeric characters. This mostly works but fails when all the words have non-alphanumeric character (which is common for single or two word subject).
With IMAP, you can read your Gmail on multiple devices, and messages and folders are synced in real-time. For the Gmail IMAP settings to work in your email client, IMAP access must be enabled in Gmail online.
IMAP is a standard email protocol that stores email messages on a mail server and it also allows the end user or application to view and manipulate the messages as though they were stored locally on the end user's computing device(s). The IMAP is required for the following cloudHQ operations: Backup of Gmail.
I'm guessing that GMail search goes by the idea that only whole alphanumeric words can be used as search strings..
Therefore you'd have to remove all non-alphanumerics from your search string, and it will work...
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