PHP code example of notideus / laravel-notideus

1. Go to this page and download the library: Download notideus/laravel-notideus 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/ */

    

notideus / laravel-notideus example snippets


use Notideus\Laravel\Facades\Notideus;

$email = Notideus::emails()->send([
    'from' => 'Acme Inc <[email protected]>',
    'to' => ['[email protected]'],
    'subject' => 'Welcome',
    'html' => '<p>Hi {{name}}</p>',
    'variables' => ['name' => 'Jane'],
    'tags' => ['welcome'],
    'idempotency_key' => 'req-123',
]);

// config/mail.php
'mailers' => [
    'notideus' => [
        'transport' => 'notideus',
    ],
],

use Illuminate\Notifications\Notification;
use Notideus\Laravel\Notifications\NotideusChannel;

final class WelcomeNotification extends Notification
{
    /** @return array<string> */
    public function via(mixed $notifiable): array
    {
        return [NotideusChannel::class];
    }

    /** @return array<string, mixed> */
    public function toNotideus(mixed $notifiable): array
    {
        return [
            'from' => 'Acme <[email protected]>',
            'subject' => 'Welcome',
            'html' => '<p>Hi Jane</p>',
        ];
    }
}

use Notideus\NotideusException;

try {
    Notideus::emails()->send([…]);
} catch (NotideusException $e) {
    if ($e->getErrorCode() === 'from_domain_not_verified') { … }
    if ($e->getErrorCode() === 'rate_limited') {
        $e->getRetryAfter(); // seconds to wait
    }
    $e->getStatus(); // HTTP status
}
bash
php artisan vendor:publish --tag=notideus-config