Skip to content

With outlook mail servers, the charset shouldn't be send with the imap_search #100

Closed
@tkayfun

Description

@tkayfun

Hi Webklex,

Firstly, thanks for the great package!

I encountered some problems today with the package, which is actually an edge case..

With every mayor mail server besides Microsofts (outlook) imap servers, the charset shouldn't be send with the imap search. For some reason, if we send the default UTF-8 charset with the imap_search, every search criteria besides ALL doesn't work.. If I leave it blank, every search criteria works :)

For myself I added a check if it is a microsoft account (@outlook.com / @hotmail.com), than the charset shouldn't be given to the imap_search, otherwise I am using the UTF-8 charset. If I didn't do this, I couldn't use search criteria like UNSEEN, SEEN, etc :)

For myself I did something like this;

Define somewhere logical (for me I implemented in the Folder class) an CONST with common microsoft domains;

CONST MICROSOFT_DOMAINS = [
        'outlook.com',
        'hotmail.com'
];

In the searchMessages function;

I tried it with setting the $charset = NIL, but it really shouldn't be passed when doing an imap_search.

.........
$query = trim($query);

if(in_array(substr(strrchr($this->getClient()->username, "@"), 1), self::MICROSOFT_DOMAINS)) {
    $availableMessages = imap_search($this->getClient()->getConnection(), $query, SE_UID);
} else {
    $availableMessages = imap_search($this->getClient()->getConnection(), $query, SE_UID, $charset);
}

.........

I'd like to hear from you, if you approve this approach I'll make a PR for you, otherwise I'd like to hear what your approach would be! 👍 :-)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions