groundmail / mautic-plugin
Send Mautic email through the Groundmail API: system and transactional email, and opt-in marketing email on its own stream
Package info
github.com/Groundmail/groundmail-mautic
Type:mautic-plugin
pkg:composer/groundmail/mautic-plugin
Requires
- php: >=8.1
- groundmail/symfony-mailer: ^0.8.4 || ^0.9
- mautic/core-lib: ^6.0 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Send Mautic's email through the Groundmail API over HTTPS: user and system email, form notifications, transactional email, and opt-in marketing email to your segments. Hard bounces, spam complaints and unsubscribes come back from Groundmail and mark the contact Do Not Contact in Mautic.
Works with Mautic 6 and 7 and PHP 8.1 or later. Licensed GPL-3.0-or-later.
Your lists must be opt-in
Groundmail sends email to people who asked for it: contacts who signed up, bought from you or opted in to your newsletter. Don't use Groundmail for cold email or for purchased, rented or scraped lists. Our acceptable use policy doesn't allow them, and accounts that send to them can be suspended. Every marketing email Mautic sends needs a working unsubscribe link (Mautic's {unsubscribe_url}).
Which stream each email uses
Groundmail sends transactional, product and newsletter email from separate IPs, so a newsletter can never slow down or hurt your password resets. The plugin picks the stream for each email:
| Mautic email | Groundmail category |
|---|---|
| User and system email (password resets, notifications), form notifications, emails sent through the API, campaign emails marked Transactional | transactional |
| Segment emails, and campaign emails marked Marketing | newsletter (default) or product |
Newsletter email needs your Groundmail account approved for newsletters: email support@groundmail.dev. Until then Groundmail refuses newsletter sends (the error says so) and nothing is sent, while transactional email keeps working. If your marketing email is about your own product to its users, such as onboarding and feature announcements, set marketing_category to product instead.
Install
composer config repositories.groundmail-mautic vcs https://github.com/Groundmail/groundmail-mautic composer require groundmail/mautic-plugin php bin/console cache:clear php bin/console mautic:plugins:reload
Or in Mautic, open Settings > Plugins and click Install/Upgrade Plugins after composer require.
Set up
- In Groundmail, verify your sending domain and create an API key under API Keys. A send-only key is enough.
- In Mautic, open Settings > Configuration > Email Settings. Set E-mail address to send mail from to an address on your verified domain.
- Under the email DSN, fill in:
| Field | Value |
|---|---|
| Scheme | groundmail+api |
| Host | default |
| Port | leave empty |
| User | leave empty |
| Password | your API key (gm_…) |
- Save, then click Send test email. To check the connection without emailing a real inbox, change your Mautic user's email to
delivered@simulator.groundmail.devfirst.
Or in config/local.php:
'mailer_dsn' => 'groundmail+api://:gm_your_key@default',
Options
Add these as rows under Options in the DSN (key and value):
| Option | Value |
|---|---|
marketing_category |
newsletter (default) or product: the stream for segment and marketing campaign email |
category |
transactional, product or newsletter: send every email on this one stream |
webhook_secret |
the signing secret of your Groundmail webhook (see below) |
A single email can also choose its stream with an X-Groundmail-Category header (transactional, product or newsletter), and add tags with X-Groundmail-Tag: name=value.
Bounces, complaints and unsubscribes
Groundmail already adds addresses that hard-bounce or complain to your suppression list and stops sending to them. To have Mautic mark those contacts Do Not Contact too:
- In Groundmail, open Webhooks and add an endpoint with the URL
https://your-mautic.example.com/mailer/callbackand the eventsemail.bounced,email.failed,email.complainedandcontact.unsubscribed. Copy the signing secret. - In Mautic's email DSN, add the option
webhook_secretwith that secret, and save.
| Groundmail event | In Mautic |
|---|---|
email.bounced (hard bounce) |
Do Not Contact: bounced |
email.failed with bounce_type: hard |
Do Not Contact: bounced |
email.complained |
Do Not Contact: unsubscribed |
contact.unsubscribed |
Do Not Contact: unsubscribed |
Block bounces (the receiving server refused the sender, not the address) don't mark the contact. Requests without a valid Groundmail-Signature are refused.
What the plugin sends
Only to https://api.groundmail.dev: each email Mautic sends (sender, recipients, subject, content, attachments, custom headers), with the category and two tags, mautic_hash (the contact's Mautic hash id) and mautic_email (the Mautic email id), so webhook events can be matched to the email. See the terms and privacy policy.
Mautic 5
Mautic 5 uses an older Symfony Mailer that this plugin doesn't support. Use the Groundmail SMTP relay instead: Scheme smtp, Host smtp.groundmail.dev, Port 587, User groundmail, Password an SMTP credential (gmsmtp_…). Everything sent over SMTP goes out as transactional email, so use it for system and transactional email only.
Development
bin/install-unit-deps.sh # dependencies without Mautic itself
vendor/bin/phpunit
Tests/e2e/run.py runs the plugin in a real Mautic, against the Groundmail API or a local mock of it; see the top of that file.
Support
Open an issue or email support@groundmail.dev. Docs · Sign up free