PHP code example of dcodegroup / laravel-logged-inbound-email

1. Go to this page and download the library: Download dcodegroup/laravel-logged-inbound-email library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dcodegroup / laravel-logged-inbound-email example snippets


use Dcodegroup\LaravelLoggedInboundEmail\Contracts\EmailBasedTenantResolver;

class SubdomainTenantResolver implements EmailBasedTenantResolver
{
    public function resolve(array $recipients): ?string
    {
        // Your own parsing/lookup logic here.
    }
}

$inbound = \Dcodegroup\LaravelLoggedInboundEmail\InboundMessage::fromArray($this->message);

use Illuminate\Bus\Queueable;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Dcodegroup\LaravelLoggedInboundEmail\Contracts\ProcessesInboundEmail;
use Dcodegroup\LaravelLoggedInboundEmail\InboundMessage;

final class HandleInboundEmail implements ProcessesInboundEmail
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    /**
     * @param  array<string, mixed>  $message
     */
    public function __construct(
        public array $message,
        public string $orgAlias = '',
    ) {}

    public function handle(): void
    {
        $inbound = InboundMessage::fromArray($this->message);

        // When using organization_in_route, resolve the tenant from $this->orgAlias.
        // Use $inbound->provider, ->subject, ->text, ->metadata, etc.
    }
}

$this->app->boot(function (): void {
    config(['inbound-email.job' => \App\Jobs\HandleInboundEmail::class]);
});
bash
php artisan vendor:publish --tag=logged-inbound-email-config