beyondcode / laravel-mailbox

Catch incoming emails in your Laravel application

Home Page:https://beyondco.de/docs/laravel-mailbox/getting-started/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class 'BeyondCode\Mailbox\Facades\Mailbox' not found

jhayg12 opened this issue · comments

I was trying to implement the laravel-mailbox on our project but got this error saying:

Class 'BeyondCode\Mailbox\Facades\Mailbox' not found

I've used something like this on the web.php file:

<?php

use Illuminate\Support\Facades\Route;
use BeyondCode\Mailbox\Facades\Mailbox;


Route::post('/laravel-mailbox/sendgrid', function () use ($router) {
    \Log::info('Webhook arrives');

    Mailbox::from(config('mail.from.address'), function (InboundEmail $email) {
        // Handle the incoming email
        \Log::info(['id' => $email->id]);
        \Log::info(['subject' => $email->subject]);
        \Log::info(['message' => $email->message]);
    });
});
"beyondcode/laravel-mailbox": "^2.2",
"laravel/framework": "^8.75",

Suggestions

  1. Try composer dumpautoload to resolve the class not found
  2. Try processing a different way to see if this works

In AppServiceProvider.php:

    protected function setupMailboxCatchAll() : void
    {
        Mailbox::catchAll(static function (InboundEmail $email) {
            $email->forward('you@your.domain');
        });
    }

Hi @colinmackinlay thanks for the reply and I've tried both of your suggestions but still getting the error:

Class 'BeyondCode\Mailbox\Facades\Mailbox' not found

Hi @colinmackinlay thanks for the reply and I've tried both of your suggestions but still getting the error:

Class 'BeyondCode\Mailbox\Facades\Mailbox' not found

That's all I do and it works fine for forwarding mail.

It does seem though as if the package is not registering.

What happens if you run php artisan package:discover --ansi?

You should see Discovered Package: beyondcode/laravel-mailbox in the output

@colinmackinlay the error is gone now I've tried to uninstall install the package and verify it using the php artisan package:discover --ansi and it shows there but it seems the Mailbox facade is still not working as expected

I've tried to use it on web.php

Route::post('/laravel-mailbox/sendgrid', function () use ($router) {
    \Log::info('Webhook arrives');

    Mailbox::from(config('mail.from.address'), function (InboundEmail $email) {
        // Handle the incoming email
        \Log::info(['id' => $email->id]);
        \Log::info(['subject' => $email->subject]);
        \Log::info(['message' => $email->message]);
    });
});

and in AppServiceProvider.php boot method

Mailbox::from(config('mail.from.address'), function (InboundEmail $email) {
        // Handle the incoming email
        \Log::info(['id' => $email->id]);
        \Log::info(['subject' => $email->subject]);
        \Log::info(['message' => $email->message]);
    });

and

protected function setupMailboxCatchAll() : void
    {
        Mailbox::catchAll(static function (InboundEmail $email) {
            $email->forward('test@mailinator.com');
        });
    }

But I did not receive any logs or forwarded emails.