Download the PHP package akhan619/laravel-ses-event-manager without Composer

On this page you can find all versions of the php package akhan619/laravel-ses-event-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ses-event-manager

Laravel Ses Event Manager

Latest Stable Version Tests PHP Version Require Total Downloads StyleCI License

Manage incoming SES email event notifications over the http/s protocols. This package provides all the set up needed to send normal and queued emails using SES and then handle the email event notifications sent by SES to http/s webhook. This includes all 10 events as listed by SES like send, bounce, open, click, etc. Database and eloquent models are provided which store the event data. Don't want to use the models provided by the package or want to handle the event differently. Don't worry! you are covered. Every part of the pacakge is implemented to be modifable by the end user.

What this package does

As mentioned this package handles the process of:

What this package doesn't do

The package will not do anything beyond what is mentioned above. So, the package won't:

If you need to set up the AWS SES/SNS resources you may look at the package Laravel Ses Tracking. The package provides a simple artisan command for setting up your AWS resources. Of course, this is completely optional and you may use any other method to set up the required resources.

FULL DISCLOSURE: I am the package author for the Laravel Ses Tracking package.

Laravel and PHP Versions

The package is written for Laravel 9 and Php 8 and above.

Installation

Via Composer

Configuration File

You can publish the configuration file using the following artisan command:

This is will publish a new configuration file called laravel-ses-event-manager.php in the config folder.

Migrations

To use the eloquent models provided by the package, you must publish the database migrations of the package using the following artisan command:

Don't forget to run the migrations using

Local Development

To test the package during local development you will need a way to actually serve the Laravel project so that AWS can send the event notifications. You may do so in many ways. One way to do so is by using a tunneling service. I personally used Expose by Beyond Code during development.

FULL DISCLOSURE: I am NOT sponsored by Beyond Code.

Requirements

To start using the package, it is assumed that the necessary set up on AWS is complete. This means:

NOTE: You don't have to confirm the SNS subscription. The package can handle them for you. If you have already completed the above, you can go to the AWS console and resend the confirmation notifications and the package will confirm them for you.

Restrictions

Since the package needs to track email events, there is a limit of one recipient per email. So fields like cc or bcc will not work and throw an exception. This is because SES will only send back one id even with multiple recipients. And with one id its' not possible to track email events correctly. If you need to send the same email to multiple recipients simply loop over the recipients like below:

Usage

The package provides the SesMailer facade. The facade mimics the Laravel Mail facade so can use it just the same. For receiving and storing the notifications successfully, you must use the facade provided by the package. This is so we can track emails by the id provided by SES.

Sending Emails

Queueing Emails

To queue emails for now or later, you must add the QueueForCustomMailer trait to your mailable. Then you may queue mails as in the framework.

Models

The package uses eloquent models to store the outgoing/incoming email status. All models are specified in the Akhan619\LaravelSesEventManager\App\Models namespace under the src/App/Models directory. The main model is the Email model which provides the following fields:

For every field above there is a Eloquent relationship which is also defined. The relationships are:

So you may use the above as:

All the relevant fields present in a given SES event are available via the Eloquent model for the event. Please refer to the model for more details. An example of the kind of data for the EmailBounce model is given below:

Custom Handler

If you don't want to use the models provided by the package you may register your own logic for handling the event by registering a callback for the given event. You will need to call the extend method of a ModelResolver instance with your callback in the boot method of a ServiceProvider. The callback will receive two parameters eventType and data. The possible values and the data they receive are:

EventType Data
MessageSent Illuminate\Mail\SentMessage
Bounce Object [The message field of a SNS notification]
Complaint Object [The message field of a SNS notification]
Delivery Object [The message field of a SNS notification]
Send Object [The message field of a SNS notification]
Reject Object [The message field of a SNS notification]
Open Object [The message field of a SNS notification]
Click Object [The message field of a SNS notification]
RenderingFailure Object [The message field of a SNS notification]
DeliveryDelay Object [The message field of a SNS notification]
Subscription Object [The message field of a SNS notification]

For example, add the following to the boot method of the AppServiceProvider which comes with the default Laravel project.

Refer to the Laravel docs or the AWS docs for more info.

Configuration

Debug Mode

You may log debug data to the default logger by setting debug to true in the config file.

Subscription Confirmation

By default, incoming subscription confirmations are automatically confirmed by the package. If you do not want this behavior, you may disable this by setting the confirm_subscription to false in the config file.

Credentials

The credentials to use for SES will be picked up from the .env file. If you wish to use a different set of credentials, you may specify them in the ses_options key in the config file.

Configuration Set/Options

The configuration set to use when sending emails to track must be specified in the .env.

If you want, you can also specify it in the config file alongwith any other options under the ses_options key in the config file.

Events

You may specify the notifications to listen for using the active_email_events key in the config file. Set the event to true to enable the event.

Webhook Routes

You must specify the routes to listen on, so that the controllers and named routes may be generated. These may be specified using the following in the config file:

So for example on a fresh Laravel project the route for delivery_delays will be generated as:

NOTE: Routes are registered only when the corresponding event is enabled.

You may specify any middleware that should be used in the route_middleware array.

Database

Make sure you have published the migration files and run php artisan migrate. By default the tables names are generated as:

If for some reason the table names are in conflict with existing tables, you may change the table prefix using the database_name_prefix key in the config file.

Disable Webhook

If for some reason you don't want the package to listen to incoming notifications, you may disable all the routes by setting handle_email_events to false in the config file.

This is will disable all the routes that were registered and partially disable the package.

NOTE: This will not disable the sending of emails. So if you have used the SesMailer facade to send emails in your code, that will continue to work.

Change log

Please see the changelog for more information on what has changed recently.

Testing

Run the tests using

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of laravel-ses-event-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^9.0|^10.0
aws/aws-php-sns-message-validator Version ^1.6
aws/aws-sdk-php Version ^3.218
symfony/psr-http-message-bridge Version ^2.0
nyholm/psr7 Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package akhan619/laravel-ses-event-manager contains the following files

Loading the files please wait ....