How to search mails from mailbox using Subject line

旧城冷巷雨未停 提交于 2019-12-12 10:16:26

问题


I am using IMAP to read a mailbox.

Now is it possible that I can search mailbox with SUBJECT LINE and FROM name as flag ?

Example: is it possible to define search criteria : imap_search($login,'SUBJECT '.$sub.' FROM'.$ToSearch); Is it allowed to use from name and subject in search for an email ?


回答1:


See the SEARCH Command section of RFC 3501 to see how to use search functionality in IMAP. An AND operation is implicit so you can just put conditions next to each other:

0001 SEARCH SUBJECT "hello world" FROM "john"

If you want an OR operation instead, you need to prefix the criteria with the OR keyword:

0002 SEARCH OR SUBJECT "hello world" FROM "john"

Note that strings are used as substring search, i.e. the FROM in these cases will match both "john" and "john@malta.com".



来源:https://stackoverflow.com/questions/23896530/how-to-search-mails-from-mailbox-using-subject-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!