# Register custom mailer transport in Mautic 5

**URL:** <https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670>\
**Category:** Mautic 5 Install/Upgrade Support\
**Created:** [April 13, 2024, 11:21pm UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670 "2024-04-13T23:21:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![g33kg1rl](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@g33kg1rl](https://forum.mautic.org/u/g33kg1rl)\
**Post date:** [April 13, 2024, 11:21pm UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/1 "2024-04-13T23:21:33Z")

</div>

**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](https://github.com/bertoost/ElasticEmail-Mailer)

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](https://github.com/bertoost/ElasticEmail-Mailer/issues/1)

I found these instructions for [Creating Custom Symfony Mailer Transports](https://albertmoreno.dev/posts/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.

---

<div class="post-metadata">

**Author:** ![g33kg1rl](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@g33kg1rl](https://forum.mautic.org/u/g33kg1rl)\
**Post date:** [April 14, 2024, 6:34am UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/2 "2024-04-14T06:34:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![g33kg1rl](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@g33kg1rl](https://forum.mautic.org/u/g33kg1rl)\
**Post date:** [April 14, 2024, 8:23am UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/3 "2024-04-14T08:23:23Z")

</div>

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\>  
> -\>parent(‘mailer.transport\_factory.abstract’)  
> -\>tag(‘mailer.transport\_factory’); `

---

<div class="post-metadata">

**Author:** ![g33kg1rl](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@g33kg1rl](https://forum.mautic.org/u/g33kg1rl)\
**Post date:** [April 14, 2024, 11:12pm UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/4 "2024-04-14T23:12:18Z")

</div>

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.

 ![brave_screenshot_info.thehomeschoolquest.com (2)](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6288e4b4486fea9f541163ac437b78a03ac98193.png)

---

<div class="post-metadata">

**Author:** ![g33kg1rl](https://avatars.discourse-cdn.com/v4/letter/g/f17d59/32.png) [@g33kg1rl](https://forum.mautic.org/u/g33kg1rl)\
**Post date:** [April 15, 2024, 2:48am UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/5 "2024-04-15T02:48:20Z")

</div>

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

/opt/mautic/vendor/symfony/mailer/Transport.php  
/opt/mautic/vendor/symfony/mailer/Exception/UnsupportedSchemeException.php  
/opt/mautic/vendor/symfony/framework-bundle/Resources/config/mailer\_transports.php  
/opt/mautic/vendor/symfony/framework-bundle/DependencyInjection/FrameworkExtension.php

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

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [April 15, 2024, 8:05am UTC](https://forum.mautic.org/t/register-custom-mailer-transport-in-mautic-5/31670/6 "2024-04-15T08:05:25Z")

</div>

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](https://github.com/omnivery/mautic-omnivery-plugin/blob/9df07de28efa216a5a39bc0ae15e285e4ecfa3f5/Mailer/Transport/MauticOmniveryTransportFactory.php) \>.
