SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 136 forks source link

Every Time I pull messages I get error message #158

Closed puogintas closed 7 years ago

puogintas commented 7 years ago

Feature request or bug

BUG

If a bug, what did you expect to happen?

I expected to pull messages as normal

If a bug, what happened?

I get this error while trying to pull unread / read messages

SSilence\ImapClient\ImapClientException: Section object have only "structure" and "body" properties. in SSilence\ImapClient\Section->__get() (line 78 /xxxxxx/ImapClient/Section.php)

If a bug, list steps to reproduce bugs.

/ define the use of ImapClient / use SSilence\ImapClient\ImapClientException; use SSilence\ImapClient\ImapConnect; use SSilence\ImapClient\ImapClient;

$conn = get_mailbox_credentials();

/ creating advanced connection to mailbox / $imap = new ImapClient([ 'flags' => [ 'service' => ImapConnect::SERVICE_IMAP, 'encrypt' => $conn['encryption'], 'validateCertificates' => ImapConnect::VALIDATE_CERT, ], 'mailbox' => [ 'remote_system_name' => $conn['mailbox'], 'port' => intval($conn['port']), ], 'connect' => [ 'username' => $conn['username'], 'password' => $conn['password'], ] ]);

$messages = $imap->getMessages();

If a bug, did you do these steps?

[] Download and use the latest stable version yes -> no stable version

[] See if the issue has already been reported not yet

[] Debug I get this error once I updated my project to latest version... Previously I commit of 61f8226.... and everything was working like a bliss... I have pulled back to version which worked and all is ok... I will keep an eye for a while and maybe later see what causes issues

mattparksjr commented 7 years ago

I will look into this!

mattparksjr commented 7 years ago

@sergey144010 as you primarily wrote the section class. How does this error occur?

puogintas commented 7 years ago

Hi,

If I use this code (using dev-master#eaf55dbb0772d5a209b62e2da875ae17c6fcbf47 commit):

try {
    /* get current credentials */
    $conn = get_mailbox_credentials();

    /* creating advanced connection to mailbox */
    $imap = new ImapClient([
        'flags' => [
            'service' => ImapConnect::SERVICE_IMAP,
            'encrypt' => $conn['encryption'],
            'validateCertificates' => ImapConnect::VALIDATE_CERT,
        ],
        'mailbox' => [
            'remote_system_name' => $conn['mailbox'],
            'port' => intval($conn['port']),
        ],
        'connect' => [
            'username' => $conn['username'],
            'password' => $conn['password'],
        ]
    ]);

    /* get all messages in INBOX */
    if($imap->countUnreadMessages() != 0) {
        $messages = $imap->getUnreadMessages();
    }

    /* Perform some actions ...... */

} catch (ImapClientException $error) {
    echo $error;
}

I get object $messages with all the messages, etc... all is good.... However, if I update library to latest version I get error at when retrieving messages, for instance:

SSilence\ImapClient\ImapClientException: Section object have only "structure" and "body" properties. in /xxxx/all/vendor/ssilence/php-imap-client/ImapClient/Section.php:44 Stack trace:

0 /xxxx/all/modules/devel/krumo/class.krumo.php(956): SSilence\ImapClient\Section->__get('krumo5908764448...')

1 /xxxx/all/modules/devel/krumo/class.krumo.php(1112): krumo::_vars(Object(SSilence\ImapClient\SubtypeBody))

2 /xxxx/all/modules/devel/krumo/class.krumo.php(794): krumo::_object(Object(SSilence\ImapClient\SubtypeBody), 'plain')

3 /xxxx/all/modules/devel/krumo/class.krumo.php(1001): krumo::_dump(Object(SSilence\ImapClient\SubtypeBody), 'plain')

4 /xxxx/all/modules/devel/krumo/class.krumo.php(1112): krumo::_vars(Object(stdClass))

5 /xxxx/all/modules/devel/krumo/class.krumo.php(794): krumo::_object(Object(stdClass), 'message')

6 /xxxx/all/modules/devel/krumo/class.krumo.php(1001): krumo::_dump(Object(stdClass), 'message')

7 /xxxx/all/modules/devel/krumo/class.krumo.php(1112): krumo::_vars(Object(SSilence\ImapClient\IncomingMessage))

8 /xxxx/all/modules/devel/krumo/class.krumo.php(794): krumo::_object(Object(SSilence\ImapClient\IncomingMessage), '...')

9 /xxxx/all/modules/devel/krumo/class.krumo.php(584): krumo::_dump(Object(SSilence\ImapClient\IncomingMessage))

10 /xxxx/all/modules/devel/krumo/class.krumo.php(1311): krumo::dump(Object(SSilence\ImapClient\IncomingMessage))

11 /xxxx/all/modules/devel/devel.module(1469): krumo(Object(SSilence\ImapClient\IncomingMessage))

12 /xxxx/all/modules/devel/devel.module(1927): krumo_ob(Object(SSilence\ImapClient\IncomingMessage))

13 /xxxx/all/modules/devel/devel.module(1863): kprint_r(Object(SSilence\ImapClient\IncomingMessage), true, NULL)

14 /xxxx/all/modules/devel/devel.module(1415) : eval()'d code(29): dpm(Object(SSilence\ImapClient\IncomingMessage))

15 /xxxx/all/modules/devel/devel.module(1415): eval()

16 {main}

Thanks,

I will investigate this more....

puogintas commented 7 years ago

P.S. I used 2.0.x-dev branch

mattparksjr commented 7 years ago

Thank you. I will continue to look at this

sergey144010 commented 7 years ago

What this?

SSilence\ImapClient\Section->__get('krumo5908764448...');

Do you somehow refer to property krumo5908764448..., for example like this?

$imap->incomingMessage->message->plain->krumo5908764448...
mattparksjr commented 7 years ago

@puogintas is this still an issue?

mattparksjr commented 7 years ago

Closed for inactivity. Open again if this is still and issue...