1. Go to this page and download the library: Download mailkube/mailkube-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/ */
use Symfony\Component\Mailer\Exception\TransportException;
try {
Mail::to($user)->send(new OrderShipped($order));
} catch (TransportException $e) {
report($e->getPrevious()); // the SDK exception, with the API's error name and request id
}
use Mailkube\Laravel\Events\WebhookReceived;
use Mailkube\Event\EmailBouncedEvent;
use Mailkube\Event\EmailDeliveredEvent;
class HandleMailkubeWebhook
{
public function handle(WebhookReceived $received): void
{
$event = $received->event;
if ($event instanceof EmailDeliveredEvent) {
Log::info('delivered', ['id' => $event->data->emailId]);
} elseif ($event instanceof EmailBouncedEvent) {
Suppression::add($event->data->bounce->recipient);
}
}
}