select-co/module-mailgun
Composer 安装命令:
composer require select-co/module-mailgun
包简介
N/A
README 文档
README
Magento 2 module that routes all outgoing Magento emails through the Mailgun HTTP API.
When enabled, the module replaces Magento's default mail transport with a plugin that submits messages to Mailgun, including HTML content and attachments. It also provides an admin configuration section with a built-in "Send Test Email" tool to validate your setup.
Features
- Send all Magento transactional emails via Mailgun API
- Supports US and EU Mailgun endpoints
- Sends HTML content and attachments
- Optional debug mode and Mailgun Request Bin (Pastebin) integration for inspecting requests
- Admin "Send Test Email" button to quickly verify configuration
Requirements
- Magento 2 (tested with 2.3.5)
- A Mailgun account with a verified sending domain
- PHP version compatible with your Magento installation
- Composer dependencies (handled via this module):
- mailgun/mailgun-php ^2.4
- php-http/multipart-stream-builder 1.0.0
Installation
You can install this module either via Composer or by placing it in app/code.
Composer (preferred)
- Require the package:
- If available via your satis/packagist:
composer require select-co/module-mailgun - If using this repository directly, add a VCS repository entry in your root composer.json and then
composer require select-co/module-mailgun.
- If available via your satis/packagist:
- Enable and set up the module:
bin/magento module:enable SelectCo_Mailgunbin/magento setup:upgrade- In production mode:
bin/magento setup:di:compileandbin/magento setup:static-content:deploy -f
Manual installation (app/code)
- Copy this directory to
app/code/SelectCo/Mailgun. - Run:
bin/magento module:enable SelectCo_Mailgunbin/magento setup:upgrade- In production mode:
bin/magento setup:di:compileandbin/magento setup:static-content:deploy -f
Configuration
Admin Path: Stores > Configuration > SelectCo Settings > Mailgun Config
-
General
- Enabled: Turn Mailgun delivery on/off. When disabled, Magento uses its default transport.
-
API
- Sending Domain Name: Your Mailgun sending domain (e.g., mg.example.com)
- API Key: Your Mailgun Private API key (stored encrypted; treated as sensitive)
- Mailgun Endpoint: Choose between:
- https://api.mailgun.net/ (US Region)
- https://api.eu.mailgun.net/ (EU Region)
-
Debug
- Debug Enabled: Enable HTTP client debug output on requests. Note: Mailgun may accept messages in test/debug flows but not deliver them; refer to your Mailgun plan for billing implications.
- Pastebin Enabled: Enable sending requests to a Mailgun Request Bin for inspection
- Pastebin Id: The request bin ID to use when Pastebin is enabled
-
Send Test Email
- Provides a From and To field and a "Send Test" button. The request is sent to the controller
selectco_mailgun/system_config_mailgun/testand the result is displayed inline.
- Provides a From and To field and a "Send Test" button. The request is sent to the controller
How it works
- The module declares a plugin on
Magento\Email\Model\Transport(see etc/di.xml). When the module is enabled,aroundSendMessageinterceptssendMessage()and delegates delivery toSelectCo\Mailgun\Model\Mailgun. - The Mailgun model builds parameters from Magento's email message object:
- to/cc/bcc/from/reply-to, subject
- html body (decoded from quoted-printable)
- attachments (filename + raw content)
- Endpoint selection:
- If Pastebin is enabled and a Pastebin Id is set, requests are sent to
http://bin.mailgun.net/{id}for inspection - Otherwise, requests are sent to the chosen Mailgun API endpoint (US/EU)
- If Pastebin is enabled and a Pastebin Id is set, requests are sent to
Email templates
- Test email template ID:
selectco_mailgun_test_email - File:
view/adminhtml/email/test_email.html
Troubleshooting
- Verify your Mailgun domain is verified and authorized to send
- Ensure DNS records (SPF/DKIM) are correctly configured for your sending domain
- Make sure the API key and endpoint match your Mailgun region
- Use Debug and/or Pastebin to inspect payloads if messages are not delivered
- Check Magento logs for exceptions and the Mailgun event logs for rejected messages
License
MIT. See LICENSE.
Support
If you have a feature request or spotted a bug or a technical problem, create a GitHub issue.
select-co/module-mailgun 适用场景与选型建议
select-co/module-mailgun 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 select-co/module-mailgun 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 select-co/module-mailgun 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Proprietary
- 更新时间: 2025-10-20