php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73640 imap_search can't search HEADER
Submitted: 2016-12-02 08:51 UTC Modified: 2016-12-02 09:12 UTC
Votes:10
Avg. Score:4.7 ± 0.6
Reproduced:9 of 9 (100.0%)
Same Version:5 (55.6%)
Same OS:2 (22.2%)
From: sistemisti-posta at csi dot it Assigned:
Status: Open Package: IMAP related
PHP Version: 7.0.13 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-12-02 08:51 UTC] sistemisti-posta at csi dot it
Description:
------------
imap_search can't search all headers released by IMAP protocol (RFC 3501).
See at https://tools.ietf.org/html/rfc3501#section-6.4.4
You can perform the following command:

  HEADER <field-name> <string>

But this option is not allowed from PHP imap_search.

Expected result:
----------------
Something like:

$string = sprintf('HEADER "%s" "%s"','Message-ID', 'dskljflsdjfskl@example.org');
imap_search($imapconn, $string, SE_UID);

This should return the uid of message with the Message-ID found.

Actual result:
--------------
At the moment, to search an header I can use this workaround:

$string = sprintf('%s "Message-ID: <%s>"','TEXT', 'dskljflsdjfskl@example.org');
imap_search($imapconn, $string, SE_UID);

But it's not safe, because with TEXT I find all occurrences of string

  "Message-ID: <dskljflsdjfskl@example.org>"

in headers or body too.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-02 09:12 UTC] sistemisti-posta at csi dot it
Ps: the current error returned with

$string = sprintf('%s %s "%s"','HEADER', 'Message-ID', 'kldjskljf@example.org');
imap_search($imapconn, $string, SE_UID);

is

 PHP Notice:  Unknown: Unknown search criterion: HEADER (errflg=2) in Unknown
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 00:01:26 2019 UTC