javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
48 stars 29 forks source link

M$-Exchange - A0012 FETCH 25 (BODY[0]) A0012 BAD Command Argument Error. 11 #11

Closed Orgoth closed 1 year ago

Orgoth commented 1 year ago

Greetings, I am currently in the process of connecting an M$-Exchange. The login via imap2_open worked, and now I wanted to start fetching messages from the server. Unfortunately this does not work, because the server only returns the message that there is a problem with an argument.

With enabled client-debug, I get the following message:

DEBUG: C: A0012 FETCH 25 (BODY[0]) 
DEBUG: S: A0012 BAD Command Argument Error. 11

Let me know what you need to help, and I will try to provide you the needed information.

Orgoth commented 1 year ago

Found the Problem. imap_fetchbody converts the section to an empty string if 0 is given. imap2_fetchbody does not do this and resulted in the mentioned error message.

    public function getExtendedHeaders()
    {
        if( $this->extHeaders === null ){

            // the sections is 0 but needs to be a empty string.
            $headersText = imap2_fetchbody($this->stream, $this->messageNumber, '0', FT_UID); 

            $this->extHeaders = new Message\ExtendedHeaders($headersText);
        }

        return $this->extHeaders;
    }