Download the PHP package aleahy/mailgun-logger without Composer

On this page you can find all versions of the php package aleahy/mailgun-logger. 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 mailgun-logger

MailgunLogger

This package allows a laravel app to receive Mailgun webhooks. It makes use of Spatie's Webhook Client Package to capture the webhooks. You then can queue jobs to process the webhooks as you see fit.

It also has a service to retrieve stored messages through the api.

Installation

Install the package using composer:

The service provider should autoregister.

You will need your mailgun signing secret in your .env file.

If you want to define jobs to respond to the webhooks, you will need to publish the config file.

Publish the config file using

You can then define your jobs in the jobs section of the mailgun-logger config file.

Make sure the key for each job you define is one of the event types defined in the Mailgun API.

You will need the migrations from the Spatie\WebhookClient Package to store the webhook calls.

If you haven't already done so, publish them using:

and run the migration:

Routing

Define a route for incoming mailgun events in your routes/web.php file using the Route macro mailgunWebhooks:

This will register a POST route to a controller in this package.

You will also need to bypass CSRF token checking for this route by adding it to the VerifyCsrfToken middleware.

Usage

Responding to Webhooks

Create a laravel job class that extends Spatie\WebhookClient\Jobs\ProcessWebhookJob to be run when the webhook is received.

As the parent class receives the webhook in the constructor, the payload can be access by $this->webhookCall->payload.

If you decide not to extend Spatie\WebhookClient\Jobs\ProcessWebhookJob, then make sure it can receive the webhook in the constructor. It is also important that the job is queueable so that Mailgun can receive a response immediately.

An example is shown below:

Once the job class is created, just add it to the jobs array in the mailgun-logger config file. The key is the event type, as listed in the Mailgun API docs, and the value is the job class name.

Getting Stored Messages

Some of the mailgun webhooks contain a url to the stored message. You can access the contents of the message using the MailgunService class.

This will return an associative array containing various forms of the message, under keys such as stripped-text, body-html, stripped-html.

You can also get the raw MIME message.

This also returns an associative array which contains the mime data under the key body-mime.

Upgrading from 0.3 to 1

Version 1.0 requires PHP 8.0 and also has upgraded Spatie\WebhookClient to version 3.1.7.\ The migrations for this package has changed, so in order to upgrade, you must add the following migration:

Credits

Much of this package was influenced by binary-cats/laravel-mailgun-webhooks.

Thanks also to Spatie for creating such amazing packages, including their Webhook Client Package which this package makes use of.


All versions of mailgun-logger with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
spatie/laravel-webhook-client Version ^3.1.7
guzzlehttp/guzzle Version ^7.3
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 aleahy/mailgun-logger contains the following files

Loading the files please wait ....