Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when copying a message. #489

Open
aon4o opened this issue Jan 8, 2024 · 0 comments
Open

Error when copying a message. #489

aon4o opened this issue Jan 8, 2024 · 0 comments

Comments

@aon4o
Copy link

aon4o commented Jan 8, 2024

Describe the bug
I'm developing a Mail Importer artisan command in a Laravel app.
I'm using Zimbra as a mail server and the IMAP protocol to connect to it.
At first glance, it looks like it's working.
I'm connecting to the mailbox, getting the wanted folder, parsing the mails, etc.
But when I have to move the parsed message to another folder, there comes a problem:
The Zimbra server uses an IMAP version that doesn't support the MOVE instruction.
I thought that if I could use the MOVE, I could use copy & delete.

That worked, the message is copied to the correct folder, but for some reason, the library throws an error and I can't understand why.

The Exception I get is:

   Webklex\PHPIMAP\Exceptions\ResponseException 

  Command failed to process:
Causes:
        - Empty response
Commands send:
        TAG17 UID FETCH 639 (FLAGS)\r\n
Responses received:
        TAG17 OK UID FETCH completed\r\n
Error occurred

  at vendor/webklex/php-imap/src/Exceptions/ResponseException.php:53
     49▕         foreach($response->getStack() as $_response) {
     50▕             $exception = self::make($_response, $debug, $exception);
     51▕         }
     52▕ 
  ➜  53▕         return new self($message."Error occurred", 0, $exception);
     54▕     }
     55▕ 
     56▕     /**
     57▕      * Generate a debug message containing all commands send and responses received

      +7 vendor frames 

  8   modules/Tickets/Console/ImportMails.php:240
      Webklex\PHPIMAP\Message::copy()
      +1 vendor frames 

  10  modules/Tickets/Console/ImportMails.php:194
      Illuminate\Console\Command::withProgressBar()

The strange thing for me is that the response says OK. Isn't that what should happen?

I have enabled the debug mode and it shows as follows:

>> TAG15 UID COPY 639 "Processed"

<< TAG15 OK [COPYUID 61 639 640] UID COPY completed
>> TAG16 SELECT "Processed"

<< * 2 EXISTS
<< * 1 RECENT
<< * OK [UIDVALIDITY 61] UIDs are valid for this mailbox
<< * OK [UIDNEXT 641] next expected UID is 641
<< * FLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $MDNSent Forwarded $Junk $NotJunk Junk JunkRecorded NonJunk NotJunk)
<< * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $MDNSent Forwarded \*)] junk-related flags are not permanent
<< * OK [HIGHESTMODSEQ 1393] modseq tracked on this mailbox
<< TAG16 OK [READ-WRITE] SELECT completed
>> TAG17 UID FETCH 639 (FLAGS)

<< TAG17 OK UID FETCH completed
--------------------------------------- Here the exception happens --------------------------------------------------------------
>> TAG18 LOGOUT

<< * BYE mail.delta.bg Zimbra IMAP4rev1 server closing connection
<< TAG18 OK LOGOUT completed

Siplified version of the code I use:

$mail_client = MailHelper::getMailbox($department);

$processed_folder = $mail_client->getFolder('Processed');
if (empty($folder)) {
    $processed_folder = $mail_client->createFolder('Processed');
}

foreach ($inbox_folder->messages()->all()->get() as $message) {
    // Message parsing...

    $message->copy($processed_folder->path);
    $message->delete();
}

Desktop:

  • OS: Linux Mint
  • PHP: 8.2
  • Laravel: 10.38
  • Sail: 1.26
  • webklex/laravel-imap: 5.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant