MageMatch Sales Email Attachments
magematch/magento2-sales-email-attachments
Automatically attaches PDF renditions of invoices, shipments, and credit memos to the matching Magento sales transactional emails, plus a configurable terms/policy document, with per-type toggles and CC/BCC support — no email template edits required.
Build Tests
Code Quality
Tested on Magento 2.4.9
Recent Test History
Each release is tested against the latest Magento version at that time.
Share This Module's Status
README
Loaded from GitHubSales Email Attachments for Magento 2
Free, open-source Magento 2 extension
by Arjun Dhiman — Adobe Commerce Certified Master
Part of the MageMatch developer ecosystem
MageMatch_SalesEmailAttachments automatically appends PDF documents and policy files to Magento sales transactional emails — no custom email template edits required.
Features
- Auto-attaches PDF renditions of invoices, shipments, and credit memos to the matching transactional email.
- Attaches a configurable Terms & Conditions or policy document (PDF, DOC, DOCX, TXT) to selected email types.
- Supports CC and BCC fields for all outgoing sales emails.
- Enable/disable each attachment type independently from the admin panel.
- Built with
declare(strict_types=1), constructor property promotion, and a cleanmatchexpression — no legacy Zend 1 code. - Compatible with Magento 2.4.4+ and PHP 8.1 through 8.4.
Troubleshooting: duplicate module registration
If you see an error like:
Module 'MageMatch_SalesEmailAttachments' ... has been already defined in 'vendor/...'.
it means Magento found the same module in both locations:
app/code/MageMatch/SalesEmailAttachmentsvendor/magematch/magento2-sales-email-attachments
Fix (Composer-based install):
rm -rf app/code/MageMatch/SalesEmailAttachments
composer install
php bin/magento setup:upgrade
php bin/magento cache:flush
Verify only one copy remains:
test -d app/code/MageMatch/SalesEmailAttachments && echo "app/code present" || echo "app/code missing"
test -d vendor/magematch/magento2-sales-email-attachments && echo "vendor present" || echo "vendor missing"
Configuration
In admin, go to:
Stores > Configuration > MageMatch Extensions > Sales Email Attachments
PDF Attachments
| Field | Description |
|---|---|
| Attach Sales PDF to Email | Enable/disable auto PDF attachment. |
| Attach PDF For | Choose one or more: Invoice, Shipment, Credit Memo. |
Terms & Conditions
| Field | Description |
|---|---|
| Attach Terms & Conditions | Enable/disable the policy document attachment. |
| Attach Terms & Conditions For | Choose email types: Order, Invoice, Shipment, Credit Memo. |
| Terms & Conditions File | Upload a .pdf, .doc, .docx, or .txt file. |
CC / BCC
| Field | Description |
|---|---|
| CC Email Address(es) | Comma-separated addresses added to every sales email. |
| BCC Email Address(es) | Comma-separated addresses added to every sales email. |
How it works
The module overrides two Magento core classes via di.xml preferences:
-
Magento\Sales\Model\Order\Email\SenderBuilder→MageMatch\SalesEmailAttachments\Mail\SenderBuilderInterceptsconfigureEmailTemplate()to append attachments before the email is sent. -
Magento\Framework\Mail\Template\TransportBuilder→MageMatch\SalesEmailAttachments\Mail\Template\TransportBuilderAdds theaddAttachment()method used bySenderBuilder.
Module Structure
Helper/Data.php Config value accessor
Mail/SenderBuilder.php Attachment injection logic
Mail/Template/TransportBuilder.php addAttachment() support
Model/Config/Backend/TacFile.php File upload backend model
Model/Config/Source/AttachPdfIn.php PDF email type source
Model/Config/Source/AttachTermsConditions.php T&C email type source
etc/adminhtml/system.xml Admin config fields
etc/acl.xml ACL resource
etc/config.xml Default config values
etc/di.xml Class preference wires
view/adminhtml/requirejs-config.js Mixin registration
view/adminhtml/web/js/store-config/
validator-rules-mixin.js Client-side file-type validation
CI Matrix
This repository includes a GitHub Actions workflow at .github/workflows/ci.yml.
Validation runs on:
- PHP
8.2 - PHP
8.4
It validates Composer metadata, PHP syntax, and XML well-formedness.
Install commands by environment
Stable production install:
composer require magematch/magento2-sales-email-attachments:^1.0
Staging/dev install (before first stable tag is visible on Packagist):
composer require magematch/magento2-sales-email-attachments:"dev-main@dev"
Installation
composer require magematch/magento2-sales-email-attachments
bin/magento module:enable MageMatch_SalesEmailAttachments
bin/magento setup:upgrade
bin/magento cache:clean
Compatibility
- Magento Open Source 2.4.x
- Adobe Commerce 2.4.x
- PHP 8.1, 8.2, 8.3
Support & Custom Development
Need custom Magento development?
Find vetted Adobe Commerce developers at
magematch.com
License
MIT License — free to use commercially
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.