PHP code example of akhan619 / laravel-ses-event-manager
1. Go to this page and download the library: Download akhan619/laravel-ses-event-manager 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/ */
akhan619 / laravel-ses-event-manager example snippets
use Akhan619\LaravelSesEventManager\Facades\SesMailer;
SesMailer::to('[email protected]')->send($someMailable);
// Or if the recipient in specified in the mailable then,
SesMailer::send($someMailable);
use Akhan619\LaravelSesEventManager\Traits\QueueForCustomMailer;
class TestMailableWithTrait extends Mailable
{
use Queueable, SerializesModels, QueueForCustomMailer;
...
}
// Then, as before
$testMailableWithTrait = new TestMailableWithTrait();
SesMailer::to('[email protected]')->later(now()->addHours(12), $testMailableWithTrait);
protected $fillable = [
'message_id', // The Ses id returned by the call to sendRawEmail
'email', // The email recipient.
'name', // Recipient name if any.
// Boolean fields to show the events that have been received for the email.
'has_send',
'has_rendering_failure',
'has_reject',
'has_delivery',
'has_bounce',
'has_complaint',
'has_delivery_delay',
'has_subscription',
'has_open',
'has_click'
];
// Has Many
clicks()
opens()
// Has One
bounce()
complaint()
delivery()
send()
reject()
renderingFailure()
deliveryDelay()
subscription()
use Akhan619\LaravelSesEventManager\App\Models\Email;
$email = Email::first();
if($mail->has_bounce) {
echo 'Email has bounced';
}
// Get the bounce data
$bounce = $email->bounce;
use Akhan619\LaravelSesEventManager\Contracts\ModelResolverContract;
public function boot(ModelResolverContract $resolver)
{
$resolver->extend('MessageSent', function($event, $data) {
// Will echo the recipient email address.
echo current($data->getOriginalMessage()->getTo())->getAddress();
});
}
// OR
public function boot()
{
$resolver = app()->make(ModelResolverContract::class);
$resolver->extend('Bounce', function($event, $data) {
// The bounce type
echo $data->bounce->bounceType;
});
}