The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

726 Modules
488 Ready
233 Need Help
🏆 Leaderboard
Actively Maintained v1.0.0

ZegacLabs Email Sender

zegaclabs/module-email-sender

Provides CLI commands to send all Magento transactional emails for testing and debugging, with options to filter by module, send single templates, scan for new core templates, and discover third-party email templates.

2
Downloads
Below average
0
GitHub Stars
1mo ago
Last Release
0
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
3 errors , 246 warnings
L1 PHPStan

Tested on Magento 2.4.8-p4

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.0.0 on Magento 2.4.8-p4
Mar 22, 2026

Share This Module's Status

ZegacLabs Email Sender Magento compatibility status badge

README

Loaded from GitHub

ZegacLabs_EmailSender

CLI tool for Magento 2 that allows developers to send all transactional emails from the command line for testing and debugging purposes.

Installation

composer require zegaclabs/module-email-sender
bin/magento module:enable ZegacLabs_EmailSender
bin/magento setup:upgrade
bin/magento cache:flush

Prerequisites

Magento must be configured to send emails through your SMTP service (Mailpit is my recommendation). Set this via CLI:

bin/magento config:set system/smtp/host <your-smtp-host>
bin/magento config:set system/smtp/port <your-smtp-port>
bin/magento config:set system/smtp/transport smtp
bin/magento config:set system/smtp/disable 0
bin/magento cache:flush

Also make sure store email identities are configured under Stores > Configuration > General > Store Email Addresses.

Commands

Test All Emails

bin/magento zegaclabs:mailer:test-all [options]

Sends all registered email templates with test data.

Options

Option Description Default
--to Recipient email address test@example.com
--store Store ID 1
--group Filter by module name (e.g. Magento_Customer, Magento_Sales, Magento_User) (all groups)
--template Send a single template by ID (none)
--dry-run List templates without sending (off)
--dev Show template file paths (off)

Examples

# List all templates without sending
bin/magento zegaclabs:mailer:test-all --dry-run

# Send all templates
bin/magento zegaclabs:mailer:test-all

# Send to a specific address
bin/magento zegaclabs:mailer:test-all --to=dev@example.com

# Send only customer-related emails
bin/magento zegaclabs:mailer:test-all --group=Magento_Customer

# Send a single template
bin/magento zegaclabs:mailer:test-all --template=contact_email_email_template

# Combine options
bin/magento zegaclabs:mailer:test-all --group=Magento_Sales --to=dev@example.com --store=2

# Show file paths for each template (useful for finding which file to edit)
bin/magento zegaclabs:mailer:test-all --dry-run --dev

The --dev flag adds the resolved file path below each template:

  ✓  New Account
     customer_create_account_email_template
     vendor/magento/module-customer/view/frontend/email/account_new.html

If a template is overridden in a theme, the path will point to app/design/ instead of vendor/.

Output

Each template reports one of these statuses:

  • — Email sent successfully
  • — Template skipped due to missing data (e.g. no orders in database)
  • — Structural partial (header/footer) — not sendable
  • — Error occurred while sending

Scan Core

bin/magento zegaclabs:mailer:scan-core [--update]

Compares Magento core email templates against the module's built-in registry. Use this when upgrading Magento to detect new or removed email templates.

Options

Option Description
--update Interactively add/remove templates (prompts [y/N] for each change)

Examples

# Report only — show what's new or removed
bin/magento zegaclabs:mailer:scan-core

# Interactively apply changes
bin/magento zegaclabs:mailer:scan-core --update

Report output

 ZegacLabs Core Email Scanner
 ──────────────────────────────────────────────────
 Registry: 47 | Magento Core: 49 | Missing: 2 | Removed: 0

 Missing templates:
  + new_template_id (Magento_NewModule, frontend)
    → vars: customer, store

 Use --update to apply changes interactively.

Interactive update

With --update, each change requires confirmation:

 [1/2] Add "new_template_id" to registry?
       Module: Magento_NewModule | Area: frontend
       Will generate: MagentoNewModuleDataProvider::getNewTemplateVars()
       Apply? [y/N] y
       ✓ Added to TemplateRegistry.php
       ✓ Generated method in MagentoNewModuleDataProvider.php

 Summary: 1 added, 0 removed, 1 skipped

New templates are added with sendable=false by default. Review the generated data provider methods and set sendable=true when the mock data is ready.


Scan Project

bin/magento zegaclabs:mailer:scan-project [--path=app/code/ZegacLabs/EmailSenderCustom]

Discovers 3rd party module email templates in the current project and generates a ZegacLabs_EmailSenderCustom module so they can be tested with test-all.

Options

Option Description Default
--path Output path for generated module (relative to Magento root) app/code/ZegacLabs/EmailSenderCustom

Examples

# Scan and generate custom module
bin/magento zegaclabs:mailer:scan-project

# Use a custom output path
bin/magento zegaclabs:mailer:scan-project --path=app/code/MyCompany/EmailsCustom

What it generates

app/code/ZegacLabs/EmailSenderCustom/
├── registration.php
├── composer.json
├── etc/
│   ├── module.xml
│   └── di.xml                              # Injects providers into SenderService
├── Model/TestEmail/DataProvider/
│   └── VendorModuleDataProvider.php         # One per 3rd party module
└── custom_templates.php                     # Template registry entries

After generation

bin/magento setup:upgrade
bin/magento zegaclabs:mailer:test-all --group=VendorName_ModuleName --dry-run
bin/magento zegaclabs:mailer:test-all --group=VendorName_ModuleName --to=dev@example.com

The generated data providers use mock data based on template variable analysis. Review and adjust the mock data in the generated provider classes for accurate previews.


Template Groups

Templates are grouped by their source Magento module. The --group option filters by module name.

Module Count Templates
Magento_Email 2 Email header, email footer (structural partials, not sendable)
Magento_Customer 9 New account, no password, confirmation, confirmed, forgot/remind/reset password, change email, change email & password
Magento_Sales 16 Order, invoice, shipment, credit memo (each: new, guest, comment, comment guest)
Magento_User 3 Admin forgot password, admin user notification, admin new user
Magento_Sitemap 1 Sitemap error
Magento_ProductAlert 1 Product alert cron error
Magento_Directory 1 Currency import error
Magento_TwoFactorAuth 2 2FA user config required, 2FA app config required
Magento_Contact 1 Contact form
Magento_Newsletter 3 Subscription confirm, success, unsubscription
Magento_SendFriend 1 Send to friend
Magento_Wishlist 1 Wishlist sharing
Magento_Catalog 2 Stock alert, price alert
Magento_Checkout 1 Payment failed
Magento_OrderCancellation 1 Order cancellation (guest)
Magento_InventoryInStorePickupSales 2 Ready for pickup, ready for pickup (guest)
(3rd party) varies Discovered by scan-project

Built-in total: 47 templates

Admin-area templates (Magento_User, Magento_Sitemap, Magento_ProductAlert, Magento_Directory, Magento_TwoFactorAuth) are marked with (Admin Template) in CLI output.

Notes

  • Sales templates (order, invoice, shipment, credit memo) load real orders from the database. If no orders exist, these templates are skipped with a status. Place a test order first to test these.
  • Invoice templates require an invoiced order, shipment templates require a shipped order, and credit memo templates require a credit memo on an order.
  • Structure templates (header/footer) are registered for completeness but cannot be sent standalone.
  • The module uses Magento's native TransportBuilder, so it works with any configured SMTP transport.
  • Custom providers are injected via di.xml using Magento's standard dependency injection — no ObjectManager usage.

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.