PHP code example of vercy / sendbyte-laravel

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

    

vercy / sendbyte-laravel example snippets


'mailers' => [
    'sendbyte' => [
        'transport' => 'sendbyte',
    ],
],

Mail::to('[email protected]')->send(new OrderReceipt($order));

// Plain text
Mail::mailer('sendbyte')->raw('Your order has shipped.', function ($message) {
    $message->to('[email protected]')
             ->from('[email protected]')
             ->subject('Shipping update');
});

// HTML
Mail::mailer('sendbyte')->html('<h4>Order shipped</h4><p>Track it here.</p>', function ($message) {
    $message->to('[email protected]')
             ->from('[email protected]')
             ->subject('Shipping update');
});

use Sendbyte\Laravel\Facades\Sendbyte;

$email = Sendbyte::sendEmail([
    'from'    => 'You <[email protected]>',
    'to'      => '[email protected]',
    'subject' => 'Your OTP',
    'html'    => '<p>Your code is 483920.</p>',
], idempotencyKey: "otp-{$user->id}-".now()->timestamp);

$status = Sendbyte::getEmail($email['id']);

Sendbyte::listEmails(['status' => 'bounced', 'limit' => 20]);

use Sendbyte\Laravel\Exceptions\SendbyteException;

try {
    Sendbyte::sendEmail([
        'from'    => 'You <[email protected]>',
        'to'      => '[email protected]',
        'subject' => 'Your OTP',
        'html'    => '<p>Your code is 483920.</p>',
    ]);
} catch (SendbyteException $e) {
    report($e);

    // $e->getMessage()   — human-readable message, 

use Sendbyte\Laravel\Events\EmailDelivered;
use Sendbyte\Laravel\Events\EmailBounced;
use Sendbyte\Laravel\Events\EmailComplained;
use Sendbyte\Laravel\Events\SendbyteWebhookReceived;

protected $listen = [
    EmailDelivered::class => [MarkReceiptDelivered::class],
    EmailBounced::class => [SuppressBouncedAddress::class],
    EmailComplained::class => [SuppressBouncedAddress::class],

    // Or catch everything in one place:
    SendbyteWebhookReceived::class => [LogSendbyteEvent::class],
};

// config/sendbyte.php
'webhook' => [
    'route' => [
        'enabled' => true,
        'path' => 'webhooks/sendbyte',
        'middleware' => ['api'],
    ],
],

Sendbyte\Laravel\Facades\Sendbyte::sendEmail([
    'from'    => '[email protected]',
    'to'      => '[email protected]',
    'subject' => 'Test from tinker',
    'html'    => '<p>It works</p>',
]);
bash
php artisan vendor:publish --tag=sendbyte-config