1. Go to this page and download the library: Download juhasev/laravel-ses 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/ */
try {
SesMail::enableAllTracking()
->to('[email protected]')
->send(new Mailable);
} catch (LaravelSesMaximumSendingRateExceeded $e) {
// Implement back off logic
} catch (LaravelSesException $e) {
$smtpCode = $e->getCode();
$smtpErrorMessage = $e->getMessage();
// Do something like back of if rate limit is reached.
)
You can, of course, disable and enable all the tracking options
namespace App\Listeners;
use App\Actions\ProcessSesEvent;
use Juhasev\LaravelSes\Factories\Events\SesBounceEvent;
use Juhasev\LaravelSes\Factories\Events\SesComplaintEvent;
use Juhasev\LaravelSes\Factories\Events\SesDeliveryEvent;
use Juhasev\LaravelSes\Factories\Events\SesOpenEvent;
use Juhasev\LaravelSes\Factories\Events\SesSentEvent;
class SesSentEventSubscriber
{
/**
* Subscribe to events
*
* @param $events
*/
public function subscribe($events)
{
$events->listen(SesBounceEvent::class, SesSentEventSubscriber::class . '@bounce');
$events->listen(SesComplaintEvent::class, SesSentEventSubscriber::class . '@complaint');
$events->listen(SesDeliveryEvent::class,SesSentEventSubscriber::class . '@delivery');
$events->listen(SesOpenEvent::class, SesSentEventSubscriber::class . '@open');
$events->listen(SesLinkEvent::class, SesSentEventSubscriber::class . '@link');
}
/**
* SES bounce event took place
*
* @param SesBounceEvent $event
*/
public function bounce(SesBounceEvent $event)
{
// Do something
}
/**
* SES complaint event took place
*
* @param SesComplaintEvent $event
*/
public function complaint(SesComplaintEvent $event)
{
// Do something
}
/**
* SES delivery event took place
*
* @param SesDeliveryEvent $event
*/
public function delivery(SesDeliveryEvent $event)
{
// Do something
}
/**
* SES Open open event took place
*
* @param SesOpenEvent $event
*/
public function open(SesOpenEvent $event)
{
// Do something
}
/**
* SES Open link event took place
*
* @param SesLinkEvent $event
*/
public function link(SesLinkEvent $event)
{
// Do something
}
}