Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IMAP search by subject fails on punctuation characters on Gmail

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).

like image 234
Nands Avatar asked Sep 29 '10 07:09

Nands


People also ask

Should IMAP be enabled in Gmail?

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.

What does Show in IMAP mean in Gmail?

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.


1 Answers

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...

like image 110
Alex Avatar answered Oct 03 '22 06:10

Alex