Webklex / laravel-imap

Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
https://www.php-imap.com
MIT License
617 stars 177 forks source link

getAttachments returns null #450

Closed Waiker closed 1 year ago

Waiker commented 1 year ago

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

Waiker commented 1 year ago

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

Webklex commented 1 year ago

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

Best regards,