elcommerce/magento2-advanced-mailer

Advanced Mailer extension for Magento 2

0.0.2 2025-03-06 17:10 UTC

This package is auto-updated.

Last update: 2025-07-06 17:47:26 UTC


README

What for this extension is designed for?

It's impossible currently to send emails with file attachments from Magento 2 class called:

Magento\Framework\Mail\Template\TransportBuilder

There were some community PRs: magento/magento2#33262

But for some starnge reasons Adobe doesn't accept such useful changes from community members. That's weird.

elcommerce/magento2-advanced-mailer is FREE of:

  • PHP Reflection API usage
  • big and ugly rewriting of TransportBuilder with huge __constructor() overload

Compatibility

  • Magento: v2.4.0 and later
  • PHP: 7.4+

Installation

install module using composer:

composer require elcommerce/magento2-advanced-mailer

then do:

bin/magento setup:upgrade
bin/magento setup:di:compile

API

There's an override in di.xml, so your TransportBuilder objects will have addAttachment() method now:

public function addAttachment(
    string $content,
    string $fileName,
    ?string $fileType = MimeInterface::TYPE_OCTET_STREAM
): TransportBuilder

As bonus you have addMimePart() method too:

public function addMimePart(object $part): TransportBuilder

Where $part is Magento\Framework\Mail\MimePart or Laminas\Mime\Part instance