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.
- 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.
- Mautic 5, 6, or 7
- PHP 8.1 or higher
Copy or clone the bundle into your Mautic plugins/ directory:
cd /path/to/mautic/plugins
git clone https://github.com/tvalimaa/MauticBounceWebhookBundle.gitThen clear the Mautic cache and reload the plugins:
php bin/console cache:clear
php bin/console mautic:plugins:reloadSet 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). |
MAILER_BOUNCE_PROVIDER=mailjet
MAILER_CALLBACK_SECRET=your-random-secretConfigure your mailer to POST events to:
https://your-mautic.example.com/mailer/callback?token=your-random-secret
Handles bounce (hard only), blocked, and spam events from the Mailjet Event API.
Handles bounce (hard only), spamreport, unsubscribe, and group_unsubscribe events from the SendGrid Event Webhook.
Handles failed (permanent only), complained, and unsubscribed events from the Mailgun Webhook API v3.
- 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.
GPL-3.0-only