# Custom plugin to override (or extend) core Email functionality

**URL:** <https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262>\
**Category:** Development\
**Created:** [September 1, 2022, 1:51pm UTC](https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262 "2022-09-01T13:51:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xsheff](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/0xsheff/32/8183_2.png) [@0xsheff](https://forum.mautic.org/u/0xsheff)\
**Post date:** [September 1, 2022, 1:51pm UTC](https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262/1 "2022-09-01T13:51:50Z")

</div>

Hi there! I want to extend the core email functionality in my custom plugin, so I need to override the \Mautic\EmailBundle\Model\EmailModel model with some additions. Creating a new model and injecting the parent one is no way for me, because i need change the default way email sending.

I want to use another api key for some emails. It will be the same email service, but just two or three accounts to use in different campaigns. So I tried to override the existing model, according to the [Symfony docs](https://symfony.com/doc/4.4/service_container/service_decoration.html) but it was unsuccessful. But even if it was success, i would like not changing the core files and do everything in the plugin only.

So the question: is it possible? And if yes, how can i do this?

---

<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:** [September 1, 2022, 2:27pm UTC](https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262/2 "2022-09-01T14:27:43Z")

</div>

I would try with:

> **[How to Work with Compiler Passes (Symfony Docs)](https://symfony.com/doc/4.4/service_container/compiler_passes.html)**

See here where compiler pass is used in mautic plugin: [mautic-extended-field/OverrideCompanyModelPass.php at 53e9c495282d6561c44f5b852d643417cfc82f3f · TheDMSGroup/mautic-extended-field · GitHub](https://github.com/TheDMSGroup/mautic-extended-field/blob/53e9c495282d6561c44f5b852d643417cfc82f3f/DependencyInjection/Compiler/OverrideCompanyModelPass.php)

---

<div class="post-metadata">

**Author:** ![0xsheff](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/0xsheff/32/8183_2.png) [@0xsheff](https://forum.mautic.org/u/0xsheff)\
**Post date:** [September 2, 2022, 8:17am UTC](https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262/3 "2022-09-02T08:17:35Z")

</div>

Thanks! That’s exactly what I need

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [September 3, 2022, 8:17pm UTC](https://forum.mautic.org/t/custom-plugin-to-override-or-extend-core-email-functionality/25262/4 "2022-09-03T20:17:57Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
