Webklex/laravel-imap

getAttachments returns null

Waiker opened this issue · 2 comments

Hello, thanks for the project!
I want to use a command and when I receive a new email, save the attachment to a file.
My command code:

   . . . 
    public function onNewMessage(Message $message){
      if ($message->getAttachments()->count() == 1) {
         $message->getAttachments()->first()->save(storage_path('frames/save'));
       }

      $this->info("New message received: ".$message->subject);
      $this->info( "New message received: ". $message->getAttachments() );
    }
   . . .

But when sending email in console I get this:

_php artisan NameMyCommand

image

p/s I use Laravel Framework 8.83.23

I don’t know what helped exactly, I rewrote the code many times and now it works.

Hi @Waiker ,
great :) Perhaps something was still cached?

Best regards,