SSilence / php-imap-client

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

Trying to get property of non-object IncomingMessage.php, line 364 #187

Closed webdevhouse closed 5 years ago

webdevhouse commented 7 years ago

Hey there, It's my first post at Github at all.

I have this issue when in my mailbox are emails from mailer deamons of type - email couldn't be delivered etc. When I delete this feedback message everythings starts to work again.

Do u need something more?

screen01

mattparksjr commented 7 years ago

Hey! Welcome to the almighty GitHub. Ill be sure to look at this when I get home. I can currently coming back from vaction. Ill let you know

webdevhouse commented 7 years ago

Thank you!

foxdirect commented 7 years ago

I can confirm that MAILER-DAEMON type emails cause an error:

Fatal error: Cannot access empty property in /php-imap-client-master/ImapClient/IncomingMessage.php on line 366

screen shot 2017-08-23 at 12 47 44 pm
mattparksjr commented 7 years ago

@sergey144010 wrote that. @sergey144010 ping if you would

iBooster commented 6 years ago

I do have the same Error when just simply use this code:

$emails = $imap->getMessages();

so this is a bug and will be fixed? (first post on github, since ever :D )

mattparksjr commented 6 years ago

This may be due yo no messages being their at all

iBooster commented 6 years ago

There are about 2600 emails in the inbox folder, so I think that's not the problem

mattparksjr commented 6 years ago

Hmm I will look into this again

iBooster commented 6 years ago

To Help you a little bit, thats the code which I use `$mailbox = 'von-gerle.de'; $username = 'myUsername'; $password = 'myPassword'; $encryption = Imap::ENCRYPT_SSL; // TLS OR NULL accepted

$imap = new Imap($mailbox, $username, $password, $encryption);

$folders = $imap->getFolders();
$output = '';
foreach($folders as $folder) {
    echo $folder;
}

// Select the folder INBOX
$imap->selectFolder('INBOX');
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();
$emails = $imap->getMessages();`

$overallMessages and $unreadMessages work like expected, just $emails give me the error. Of course I set the right Username and Password =)

mattparksjr commented 6 years ago

Hey do you mind updating an re running your code to make sure the lines march up again

iBooster commented 6 years ago

okay, i've updated it, but still the same error.

mattparksjr commented 6 years ago

it still echos from line 364 correct?

iBooster commented 6 years ago

maybe this can help you a bit: grafik

that means its 366 not 364

grafik

mattparksjr commented 6 years ago

The message is cannot access empty ???

iBooster commented 6 years ago

sorry, yes the messages is "cannot access empty property"

mattparksjr commented 6 years ago

Try and remove the \

mattparksjr commented 6 years ago

Ah! I got it! Remvoe the $ fro, subtype on that line! Let me know

iBooster commented 6 years ago

i did, now i get this 'Call to a member function __get() on null' In Line 377 maybe because there is also an $ before subtype

iBooster commented 6 years ago

okay, after i removed the $ in both lines (366, 377) i got the "cannot access empty property" but this time for line 699

grafik

mattparksjr commented 6 years ago

I will download the code tommrow after school and fully fix this

mattparksjr commented 6 years ago

Please, update your code with my leastest commits

iBooster commented 6 years ago

I am sorry that I have to ask, but how do I update with your commit ? I use composer

Edit, saw that you committed in master branch, I know what to do now

mattparksjr commented 6 years ago

No problem :) I don't remember the command by heart myself lol. Try composer update. If not just Google it lol

mattparksjr commented 6 years ago

Did that fix the issue?

mattparksjr commented 6 years ago

Herooooooooo????????

spatnynick commented 6 years ago

Hi the warning on line 699 is still occurring (and some others warnings); in attachment is output from: var_dump($typeMessage);echo("\n\n"); var_dump($this->message); die; in coding IncomingMessage.php & ln 699; there is no $this->message->typeMessage->structure existing

errout.log

mattparksjr commented 6 years ago

I will look into this later.

mattparksjr commented 6 years ago

May I see the full stack trace and error? Screenshots are okay

spatnynick commented 6 years ago

there is what I get: PHP Warning: Creating default object from empty value in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 385 PHP Notice: Undefined property: stdClass::$typeMessage in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699 PHP Notice: Trying to get property of non-object in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699 PHP Notice: Trying to get property of non-object in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699 PHP Notice: Undefined property: stdClass::$typeMessage in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699 PHP Notice: Trying to get property of non-object in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699 PHP Notice: Trying to get property of non-object in /home/aaa/utils/rf-vypisy/php-imap-client/ImapClient/IncomingMessage.php on line 699

2017-10-07 16:53 GMT+02:00 Matthew Parks notifications@github.com:

May I see the full stack trace and error? Screenshots are okay

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SSilence/php-imap-client/issues/187#issuecomment-334940540, or mute the thread https://github.com/notifications/unsubscribe-auth/APLGv5jgRYpTv7jvKxh91AXL_CkpQBUEks5sp5CFgaJpZM4O5PZB .

wp-entwickler-at commented 6 years ago

hey there! I got the same problem and the solution is quiet easy in getBody() in IncomingMessage.php

grafik

Some Mails don't have a plaintext mailbody. So you would try to give $objNew a NULL property! That is the problem, my code is a possible solution. Greetz and keep up the good work!

Edit: This is also in the official docs: http://php.net/manual/en/function.imap-fetch-overview.php#25978

GregJohnStewart commented 6 years ago

I am having a separate but very similar issue on line 708 of that file:

Notice: Trying to get property of non-object in ... /ImapClient/IncomingMessage.php line 708

I am just trying to set it up, so I am unsure if it is a real bug or I have not setup my connection correctly yet...

mattparksjr commented 6 years ago

Hey, can you share your connection code?

GregJohnStewart commented 6 years ago

Using the advanced constructor;

new ImapClient([ 'flags' => [ 'service' => ImapConnect::SERVICE_IMAP, 'encrypt' => ImapConnect::ENCRYPT_SSL, 'validateCertificates' => ImapConnect::NOVALIDATE_CERT, ], 'mailbox' => [ 'remote_system_name' => "<host>.com", ], 'connect'=>[ 'username'=>"<username>", 'password'=>"<password>" ] ])

mattparksjr commented 6 years ago

It may be trying to use an ssl connection and ignoring certification

cbielich commented 5 years ago

I am having the same issue where after $emails = $imap->getMessages(); it breaks. But this is only happening to me when I access a office365 account. I tried adding wp-entwickler-at suggestion but that didn't work.