laravel-imap
laravel-imap copied to clipboard
Call to a member function idle() on null
Describe the bug when trying to use the console command "artisan imap:idle" I get from ImapIdleCommand.php the error message "Error Call to a member function idle() on null" after some debugging I found that checkFolder() works and getFolder() returns null.
To Reproduce
$foldername = "INBOX";
$info = $client->checkFolder($foldername);
$folder = $client->getFolder($foldername);
dump($info,$folder);
^ array:5 [
"exists" => "3"
"recent" => "0"
"uidvalidity" => 1
"uidnext" => 4
"flags" => array:1 [
0 => array:5 [
0 => "\Flagged"
1 => "\Seen"
2 => "\Answered"
3 => "\Deleted"
4 => "\Draft"
]
]
]
^ null
Expected behavior After running the console command "artisan imap:idle", i expect it to run normally and listen for new messages.
Desktop / Server
- OS: Red Hat Enterprise Linux release 8.6 (Ootpa)
- PHP: 8.0.13
- Version: 2.4
- Server: Domino IMAP4 Server Release 11.0.1FP5
Additional context
config:
<?php
/*
* File: imap.php
* Category: config
* Author: M. Goldenbaum
* Created: 24.09.16 22:36
* Updated: -
*
* Description:
* -
*/
return [
/*
|--------------------------------------------------------------------------
| IMAP default account
|--------------------------------------------------------------------------
|
| The default account identifier. It will be used as default for any missing account parameters.
| If however the default account is missing a parameter the package default will be used.
| Set to 'false' [boolean] to disable this functionality.
|
*/
'default' => env('IMAP_DEFAULT_ACCOUNT', 'default'),
/*
|--------------------------------------------------------------------------
| Default date format
|--------------------------------------------------------------------------
|
| The default date format is used to convert any given Carbon::class object into a valid date string.
| These are currently known working formats: "d-M-Y", "d-M-y", "d M y"
|
*/
'date_format' => 'd-M-Y',
/*
|--------------------------------------------------------------------------
| Available IMAP accounts
|--------------------------------------------------------------------------
|
| Please list all IMAP accounts which you are planning to use within the
| array below.
|
*/
'accounts' => [
'default' => [// account identifier
'host' => env('IMAP_HOST', 'localhost'),
'port' => env('IMAP_PORT', 993),
'protocol' => env('IMAP_PROTOCOL', 'imap'), //might also use imap, [pop3 or nntp (untested)]
'encryption' => env('IMAP_ENCRYPTION', 'false'), // Supported: false, 'ssl', 'tls', 'notls', 'starttls'
'validate_cert' => env('IMAP_VALIDATE_CERT', false),
'username' => env('IMAP_USERNAME', '[email protected]'),
'password' => env('IMAP_PASSWORD', 'password'),
'authentication' => env('IMAP_AUTHENTICATION', null),
'proxy' => [
'socket' => null,
'request_fulluri' => false,
'username' => null,
'password' => null,
]
],
],
/*
|--------------------------------------------------------------------------
| Available IMAP options
|--------------------------------------------------------------------------
|
| Available php imap config parameters are listed below
| -Delimiter (optional):
| This option is only used when calling $oClient->
| You can use any supported char such as ".", "/", (...)
| -Fetch option:
| IMAP::FT_UID - Message marked as read by fetching the message body
| IMAP::FT_PEEK - Fetch the message without setting the "seen" flag
| -Fetch sequence id:
| IMAP::ST_UID - Fetch message components using the message uid
| IMAP::ST_MSGN - Fetch message components using the message number
| -Body download option
| Default TRUE
| -Flag download option
| Default TRUE
| -Message key identifier option
| You can choose between 'id', 'number' or 'list'
| 'id' - Use the MessageID as array key (default, might cause hickups with yahoo mail)
| 'number' - Use the message number as array key (isn't always unique and can cause some interesting behavior)
| 'list' - Use the message list number as array key (incrementing integer (does not always start at 0 or 1)
| 'uid' - Use the message uid as array key (isn't always unique and can cause some interesting behavior)
| -Fetch order
| 'asc' - Order all messages ascending (probably results in oldest first)
| 'desc' - Order all messages descending (probably results in newest first)
| -Disposition types potentially considered an attachment
| Default ['attachment', 'inline']
| -Common folders
| Default folder locations and paths assumed if none is provided
| -Open IMAP options:
| DISABLE_AUTHENTICATOR - Disable authentication properties.
| Use 'GSSAPI' if you encounter the following
| error: "Kerberos error: No credentials cache
| file found (try running kinit) (...)"
| or ['GSSAPI','PLAIN'] if you are using outlook mail
| -Decoder options (currently only the message subject and attachment name decoder can be set)
| 'utf-8' - Uses imap_utf8($string) to decode a string
| 'mimeheader' - Uses mb_decode_mimeheader($string) to decode a string
|
*/
'options' => [
'delimiter' => '/',
'fetch' => \Webklex\PHPIMAP\IMAP::FT_PEEK,
'sequence' => \Webklex\PHPIMAP\IMAP::ST_MSGN,
'fetch_body' => true,
'fetch_flags' => true,
'message_key' => 'list',
'fetch_order' => 'asc',
'dispositions' => ['attachment', 'inline'],
'common_folders' => [
"root" => "INBOX",
"junk" => "INBOX/Junk",
"draft" => "INBOX/Drafts",
"sent" => "INBOX/Sent",
"trash" => "INBOX/Trash",
],
'open' => [
// 'DISABLE_AUTHENTICATOR' => 'GSSAPI'
],
'decoder' => [
'message' => 'utf-8', // mimeheader
'attachment' => 'utf-8' // mimeheader
]
],
/*
|--------------------------------------------------------------------------
| Available events
|--------------------------------------------------------------------------
|
*/
'events' => [
"message" => [
'new' => \Webklex\IMAP\Events\MessageNewEvent::class,
'moved' => \Webklex\IMAP\Events\MessageMovedEvent::class,
'copied' => \Webklex\IMAP\Events\MessageCopiedEvent::class,
'deleted' => \Webklex\IMAP\Events\MessageDeletedEvent::class,
'restored' => \Webklex\IMAP\Events\MessageRestoredEvent::class,
],
"folder" => [
'new' => \Webklex\IMAP\Events\FolderNewEvent::class,
'moved' => \Webklex\IMAP\Events\FolderMovedEvent::class,
'deleted' => \Webklex\IMAP\Events\FolderDeletedEvent::class,
],
"flag" => [
'new' => \Webklex\IMAP\Events\FlagNewEvent::class,
'deleted' => \Webklex\IMAP\Events\FlagDeletedEvent::class,
],
],
/*
|--------------------------------------------------------------------------
| Available masking options
|--------------------------------------------------------------------------
|
| By using your own custom masks you can implement your own methods for
| a better and faster access and less code to write.
|
| Checkout the two examples custom_attachment_mask and custom_message_mask
| for a quick start.
|
| The provided masks below are used as the default masks.
*/
'masks' => [
'message' => \Webklex\PHPIMAP\Support\Masks\MessageMask::class,
'attachment' => \Webklex\PHPIMAP\Support\Masks\AttachmentMask::class
]
];
telnet test:
* OK Domino IMAP4 Server Release 11.0.1FP5 ready
a001 login user pass
a001 OK LOGIN completed
a002 list
* LIST (\Noselect) "\\" ""
a002 OK LIST completed
a003 select inbox
* 2 EXISTS
* 0 RECENT
* OK [UNSEEN 1] Message 1 is first unseen
* OK [UIDVALIDITY 1] UIDs valid
* OK [UIDNEXT 3] Predicted next UID
* FLAGS (\Flagged \Seen \Answered \Deleted \Draft)
* OK [PERMANENTFLAGS (\Flagged \Seen \Answered \Deleted \Draft \*)] Permanent flags
a003 OK [READ-WRITE] SELECT completed
a004 select INBOX
* 2 EXISTS
* 0 RECENT
* OK [UNSEEN 1] Message 1 is first unseen
* OK [UIDVALIDITY 1] UIDs valid
* OK [UIDNEXT 3] Predicted next UID
* FLAGS (\Flagged \Seen \Answered \Deleted \Draft)
* OK [PERMANENTFLAGS (\Flagged \Seen \Answered \Deleted \Draft \*)] Permanent flags
a004 OK [READ-WRITE] SELECT completed
a005 logout
* BYE logging out
a005 OK LOGOUT completed
Connection closed by foreign host.
Hi @eisler , many thanks for your report. Can you check if you can get a hold on a call stack?
The Command utilizes the default account and the folder INBOX.
Given that you've tested both and verified that they both exist / work, I'm a bit lost to imagine what could cause this issue in your case.
To further investigate, try to create a similar command and debug it step by step.
Best regards,
Hello @Webklex, Since I have found a quick and dirty solution, this has been running smoothly for a few months. Now I would like to ask for a real solution. How can we debug the problem?
Hi @eisler , sure but I'm not sure what problem you are facing. Can you please share the call stack? This would give some insight :)
Please make sure you are using the latest version - or if you want to use the latest changes, give the master a try.
Best regards,