tvalimaa / mautic-bounce-webhook-bundle
Mautic plugin that processes mailer transport webhook callbacks for bounce and spam events (Mailjet, SendGrid, Mailgun).
Package info
github.com/tvalimaa/MauticBounceWebhookBundle
Type:mautic-plugin
pkg:composer/tvalimaa/mautic-bounce-webhook-bundle
Requires
- php: ^8.1
- ext-json: *
- mautic/core-lib: ^5.0|^6.0|^7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
An unofficial Mautic plugin that processes mailer transport webhook callbacks for bounce and spam events, automatically adding contacts to the Do Not Contact (DNC) list.
Supports Mailjet, SendGrid, and Mailgun out of the box. Adding new providers requires only implementing a single interface.
How it works
- Your mailer sends a webhook POST to Mautic's transport callback endpoint.
- The bundle selects the correct provider based on the
MAILER_BOUNCE_PROVIDERenv var. - The provider fingerprints the payload to confirm it matches the expected format.
- Bounce, spam, and unsubscribe events are recorded via Mautic's
TransportCallback, which marks the contact as DNC.
Hard bounces and permanent failures add contacts with DoNotContact::BOUNCED. Spam complaints and unsubscribes use DoNotContact::UNSUBSCRIBED. Soft bounces are logged and skipped.
Requirements
- Mautic 5, 6, or 7
- PHP 8.1 or higher
Installation
Copy or clone the bundle into your Mautic plugins/ directory:
cd /path/to/mautic/plugins
git clone https://github.com/tvalimaa/MauticBounceWebhookBundle.git
Then clear the Mautic cache and reload the plugins:
php bin/console cache:clear php bin/console mautic:plugins:reload
Configuration
Set the following environment variables (e.g. in .env.local):
| Variable | Required | Description |
|---|---|---|
MAILER_BOUNCE_PROVIDER |
Yes | Active provider: mailjet, sendgrid, or mailgun |
MAILER_CALLBACK_SECRET |
No | Secret token appended as ?token= to the webhook URL. When unset the endpoint is unrestricted (useful for local dev). |
Example
MAILER_BOUNCE_PROVIDER=mailjet MAILER_CALLBACK_SECRET=your-random-secret
Webhook URL
Configure your mailer to POST events to:
https://your-mautic.example.com/mailer/callback?token=your-random-secret
Supported providers
Mailjet
Handles bounce (hard only), blocked, and spam events from the Mailjet Event API.
SendGrid
Handles bounce (hard only), spamreport, unsubscribe, and group_unsubscribe events from the SendGrid Event Webhook.
Mailgun
Handles failed (permanent only), complained, and unsubscribed events from the Mailgun Webhook API v3.
Adding a custom provider
- Create a class implementing
BounceProviderInterfacein theProvider/directory. - Add it as a constructor argument in
BounceProviderRegistry. - Register it with a key in
$this->providers. - Set
MAILER_BOUNCE_PROVIDERto the new key.
License
GPL-3.0-only