Module Installation
When to Use
After Mailgun account is set up, domain is added, and DNS records are verified. Run on the Drupal codebase, then deploy.
Decision
| Step | Command | Notes |
|---|---|---|
| Install via Composer | ddev composer require drupal/mailgun:^2.1 |
Pulls mailgun/mailgun-php SDK transitively |
| Enable module | ddev drush en mailgun -y |
Add mailsystem if you'll route per-module emails |
| Optional sub-module | ddev drush en mailgun_test_form -y |
Adds a UI test sender at /admin/config/services/mailgun/test |
| Optional queue plugin | (no separate enable; configured via Mailsystem UI) | "Mailgun mailer (queued)" plugin appears in Mailsystem dropdowns once mailgun is enabled |
Pattern
Minimum installation
# Composer
ddev composer require drupal/mailgun:^2.1
# Enable
ddev drush en mailgun -y
# Verify
ddev drush pm:list --status=enabled --type=Module | grep mailgun
With Mailsystem for per-module routing
ddev composer require drupal/mailgun:^2.1 drupal/mailsystem
ddev drush en mailgun mailsystem -y
With Key module (interim — patch required as of April 2026)
# composer.json
"drupal/mailgun": "^2.1",
"drupal/key": "^1.18",
"cweagans/composer-patches": "^1.7"
# patches block
"extra": {
"patches": {
"drupal/mailgun": {
"Add Key module support (issue 3452693)":
"https://www.drupal.org/files/issues/2025-10-09/3452693_add-key-support-9.patch"
}
}
}
ddev composer install
ddev drush en mailgun key -y
Common Mistakes
- Wrong: Using
^2.0constraint → Right: Use^2.1to get 2.1.0 (July 2025 release) and forward; 2.0.0 is from 2023 and lacks recent fixes. - Wrong: Installing both
drupal/mailgunANDdrupal/symfony_mailer(Mailer Plus override mode) → Right: They fight for the mail interface. See Module Decision. - Wrong: Skipping
drupal/mailsystemand trying to route per-module emails through admin UI → Right: Without mailsystem, you only get a globaldefaultswitch insystem.mail.yml.