Register custom mailer transport in Mautic 5

Your software
My Mautic version is: Mautic 5.0.3
My PHP version is: 8.1.27
My Database type and version is: 10.11.6-MariaDB-0+deb12u1

I am trying to add Elastic Email support to my Mautic installation using Symfony-mailer.

I have installed this mailer transport from github: GitHub - bertoost/ElasticEmail-Mailer: A Symfony Mailer implemtation for Elastic Email API

According to the developer, I need to register this new mailer.transport in the services.yaml file for Symfony support: Questions on usage · Issue #1 · bertoost/ElasticEmail-Mailer · GitHub

I found these instructions for Creating Custom Symfony Mailer Transports

Can someone direct me to the right place to declare this new transport in Mautic?

I have tried editing the file under app/config/services.php, but that threw errors. I tried adding a custom file under config/services.php (alongside the local.php file). I also tried to add it under vendor/bertoost/elasticemail-mailer/services.php.

I will buy you a case of your beverage of choice if you can help me figure this out. :wink:

Here is the code that I have been trying to find the right place for. Perhaps there is an error in the code itself:

// config/services.php
use bertoost\Mailer\ElasticEmail\Transport\ElasticEmailTransportFactory;

$services->set(‘mailer.transport_factory.custom’, ElasticEmailTransportFactory::class>
->tag(‘mailer.transport_factory’); `

The develop has updated the mail transport to register in symfony-mailer (I’m impressed with the quick turn around), but Mautic isn’t picking up still.

I have installed the symfony/sendgrid-mailer and found it is registered in the following files:


I have edited these files to include ElasticEmail-Mailer too and this is the error I am getting:

PHP Fatal error: Cannot use bertoost\Component\Mailer\Transport\ElasticEmail\ElasticEmailTransportFactory as ElasticEmailTransportFactory because the name is already in use in /opt/mautic/vendor/symfony/framework-bundle/Resources/config/mailer_transports.php on line 29

In mailer_transports.php line 29:

Compile Error: Cannot use bertoost\Component\Mailer\Transport\ElasticEmail\ElasticEmailTransportFact
ory as ElasticEmailTransportFactory because the name is already in use

Maybe this mautic plugin can help a bit as a blueprint: < mautic-omnivery-plugin/Mailer/Transport/MauticOmniveryTransportFactory.php at 9df07de28efa216a5a39bc0ae15e285e4ecfa3f5 · omnivery/mautic-omnivery-plugin · GitHub >.