drupal-mail
Skill81 starsChanged 42 days agoMITView on GitHub
Drupal mail system configuration for local testing (Mailpit) and production (Mailchimp Transactional). Covers HTML email rendering, Content-Type headers, sender/formatter plugins, and troubleshooting. Use when testing emails locally, debugging email issues, or configuring mail delivery.
In this repository25 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- acquia-sourceSkill
- canvas-contributionSkill
- claude-code-mcp-setupSkill
- design-reviewSkill
- drupal-api-endpointsSkill
- drupal-at-your-fingertipsSkill
- drupal-canvas-sdcSkill
- drupal-canvasSkill
- drupal-config-mgmtSkill
- drupal-config-reconcileSkill
- drupal-contrib-mgmtSkill
- drupal-ddevSkill
- drupal-deploy-safetySkill
- drupal-performanceSkill
- drupal-search-apiSkill
- drupal-simple-oauthSkill
- drupal-testingSkill
- drupal-views-patternsSkill
- drupal-vite-themeSkill
- ivangrynenko-cursorrules-drupalSkill
- mockup-paritySkill
- sentry-integrationSkill
- skill-developerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 52
Content-Type Header: Must be set to text/html for HTML rendering
- Very specific: line 98
Use inline styles (email clients strip <style> tags)
- Very specific: line 158
Check Headers tab: Content-Type: text/html.
- Distinctive: line 159
Check HTML tab: Proper styled rendering
- Distinctive: line 160
Check Text tab: Plain text fallback
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Drupal Mail System Configuration
Quick Reference
Local Testing (DDEV Mailpit)
Working configuration for HTML emails in Mailpit:
# mailsystem.settings
defaults:
sender: php_mail
formatter: mailchimp_transactional_mailEnable/disable notifications:
# Check if notifications are disabled
ddev drush state:get my_notifications.disabled
# Enable notifications (for local testing)
ddev drush state:set my_notifications.disabled 0
# Disable notifications (to stop local emails)
ddev drush state:set my_notifications.disabled 1View Mailpit:
- URL: https://
<project>.ddev.site:8026 - Or run:
ddev mailpit
Production Configuration
Mailchimp Transactional (Mandrill) for sending:
# mailsystem.settings
defaults:
sender: mailchimp_transactional_mail
formatter: mailchimp_transactional_mailMail System Architecture
Key Concepts
- Sender: The plugin that actually sends the email (SMTP, PHP mail(), API)
- Formatter: The plugin that formats the email body (converts HTML, wraps content)
- Content-Type Header: Must be set to
text/htmlfor HTML rendering
Plugin Combinations
| Environment | Sender | Formatter | HTML Works? | Notes |
| Local (Mailpit) | php_mail | mailchimp_transactional_mail | Yes | Recommended for local testing |
| Local (Mailpit) | php_mail | php_mail | No | Strips HTML to plain text |
| Production | mailchimp_transactional_mail | mailchimp_transactional_mail | Yes | Uses Mandrill API |
| Production | symfony_mailer | symfony_mailer | Yes | Requires SMTP config |
HTML Email Requirements
Content-Type Header
Critical: Module must set Content-Type header in hook_mail_alter():
/**
* Implements hook_mail_alter().
*/
function my_notifications_mail_alter(&$message) {
if ($message['module'] === 'my_notifications') {
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
}
}Without this, HTML renders as plain text even with correct formatter.
Message Template Format
Config entity format (message.template.*.yml):
text:
-
value: |-
Subject line with [tokens]
<p style="margin: 0 0 16px 0; color: #333;">HTML body content</p>
format: full_htmlKey points:
- First line = email subject (extracted, stripped of HTML)
- Rest = HTML email body
- Use inline styles (email clients strip
<style>tags) format: full_htmlenables HTML rendering
Configuration Commands
Check Current Config
# View mail system settings
ddev drush cget mailsystem.settings
# View notification plugin settings
ddev drush cget my_notifications.settings
# Check global disable state
ddev drush state:get my_notifications.disabledSwitch Between Local and Production
For local testing:
# Enable HTML email capture in Mailpit
ddev drush cset mailsystem.settings defaults.sender php_mail -y
ddev drush cset mailsystem.settings defaults.formatter mailchimp_transactional_mail -y
ddev drush state:set my_notifications.disabled 0
ddev drush crReset to production:
ddev drush cset mailsystem.settings defaults.sender mailchimp_transactional_mail -y
ddev drush cset mailsystem.settings defaults.formatter mailchimp_transactional_mail -y
ddev drush state:set my_notifications.disabled 1
ddev drush crTesting Notifications
Test Commands
Give your notification module drush test commands so each template can be fired on demand, e.g.:
# Test entity deleted notification
ddev drush my-notifications:test-entity-deleted
# Test entity updated notification
ddev drush my-notifications:test-entity-updated
# Test comment notification
ddev drush my-notifications:test-comment
# Test group invitation
ddev drush my-notifications:test-invitationVerify Email in Mailpit
- Open https://
<project>.ddev.site:8026 - Check Headers tab:
Content-Type: text/html; charset=UTF-8 - Check HTML tab: Proper styled rendering
- Check Text tab: Plain text fallback
Mailpit API
# List recent messages
curl -sk "https://<project>.ddev.site:8026/api/v1/messages" | jq '.messages[:3]'
# Get specific message with HTML
curl -sk "https://<project>.ddev.site:8026/api/v1/message/{ID}" | jq '{Subject, HTML}'
# Delete all messages
curl -sk -X DELETE "https://<project>.ddev.site:8026/api/v1/messages"Troubleshooting
No Emails Appearing
- Check global disable state:
ddev drush state:get my_notifications.disabled # If TRUE, run: ddev drush state:set my_notifications.disabled 0 - Check sender plugin:
ddev drush cget mailsystem.settings defaults.sender # For Mailpit: should be php_mail - Check DDEV is running:
ddev describe | grep -i mail - Test raw PHP mail:
ddev exec "php -r \"mail('test@example.com', 'Test', 'Body');\"" # Should appear in Mailpit immediately
HTML Not Rendering (Shows Raw Tags)
- Check formatter plugin:
ddev drush cget mailsystem.settings defaults.formatter # Should be mailchimp_transactional_mail for HTML - Check Content-Type header in hook_mail_alter():
grep -r "Content-Type.*text/html" web/modules/custom/ - Check template format:
grep "format:" config/default/message.template.*.yml # Should show: format: full_html
Emails Sending to Production
- Check sender plugin:
ddev drush cget mailsystem.settings defaults.sender # If mailchimp_transactional_mail, emails go to real addresses! - Switch to local capture:
ddev drush cset mailsystem.settings defaults.sender php_mail -y
Module Dependencies
- mailsystem: Routes mail through configured plugins
- mailchimp_transactional: Provides Mandrill integration
- message: Provides template-based message entities
- my_notifications: Custom notification system
File Locations
- Mail config:
config/default/mailsystem.settings.yml - Notification settings:
config/default/my_notifications.settings.yml - Message templates:
config/default/message.template.*.yml - Notification processor:
web/modules/custom/my_notifications/src/Plugin/QueueWorker/NotificationProcessor.php - Mail alter hook:
web/modules/custom/my_notifications/my_notifications.module
Apply to Files
config/default/mailsystem.settings.ymlconfig/default/my_notifications.settings.ymlconfig/default/message.template.*.ymlweb/modules/custom/my_notifications/**/*.phpweb/modules/custom/my_notifications/*.module
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

