PHP code example of ag84ark / aws-ses-bounce-complaint-handler

1. Go to this page and download the library: Download ag84ark/aws-ses-bounce-complaint-handler 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/ */

    

ag84ark / aws-ses-bounce-complaint-handler example snippets


class VerifyCsrfToken extends Middleware
{
    protected $except = [
        // ... 
        'amazon-sns/notifications'
    ];
}

$email = "[email protected]";
AwsSesBounceComplaint::canSendToEmail($email);

class EventServiceProvider {

    protected $listen = [
        // ...
        Illuminate\Mail\Events\MessageSending::class => [
            App\Listeners\CheckEmailAddressBeforeSending::class,
        ],
    ];
}


 
 namespace App\Listeners;
 
 use ag84ark\AwsSesBounceComplaintHandler\AwsSesBounceComplaintHandler;
 use Illuminate\Mail\Events\MessageSending;
 
 class CheckEmailAddressBeforeSending
 {
     public function __construct()
     {
         //
     }
 
     public function handle(MessageSending $event): bool
     {
         $email = $event->data['email'];
         if (!AwsSesBounceComplaintHandler::canSendToEmail($email)) {
             \Log::info(json_encode($event->data));
             // log the information in some way   
             return false;
         }
 
 
         return true;
 
     }
 }


$email = "[email protected]";
AwsSesBounceComplaint::ignoreEmail($email);

$email = "[email protected]";
AwsSesBounceComplaint::clearEmail($email);
bash
php artisan vendor:publish --provider="ag84ark\AwsSesBounceComplaintHandler\AwsSesBounceComplaintHandlerServiceProvider" --tag="migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="ag84ark\AwsSesBounceComplaintHandler\AwsSesBounceComplaintHandlerServiceProvider" --tag="config"