# Notification Email for internal emails (alias)

**URL:** https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060
**Category:** User
**Created:** [November 26, 2024, 3:16pm UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060 "2024-11-26T15:16:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [November 26, 2024, 3:16pm UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060/1 "2024-11-26T15:16:00Z")

</div>

Hi,

I’m setting a trigger to send an email when doing a specific workflow or setting a flag in a model. In notification email module, all recipients are Many2One fields. I just want to use the trigger to send an email to an internal department of the company: [accouting@company.com](mailto:accouting@company.com), [sales@company.com](mailto:sales@company.com),…  
Fallback user recipient field is only displayed if the recipient field is used.  
How to allow such internal emails as recipients ?  
Thanks.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [November 27, 2024, 11:16am UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060/2 "2024-11-27T11:16:25Z")

</div>

I made a custo on notification email module to add a “recipient email” field for such trigger that send an email to a specific department of the company.

```auto

from trytond.i18n import gettext
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.tools.email_ import EmailNotValidError, validate_email

from .exceptions import EMailValidationError

class Email(metaclass=PoolMeta):
    __name__ = 'notification.email'

    recipient_email = fields.Char("Recipient Email",
        help="Will take priority over recipients fields if filled")

    def _get_to(self, record):
        pool = Pool()
        Lang = pool.get('ir.lang')
        to, languages = super()._get_to(record)
        if self.recipient_email:
            try:
                validate_email(self.recipient_email)
            except EmailNotValidError as e:
                raise EMailValidationError(gettext(
                    'puck.msg_email_invalid',
                    record=record.rec_name,
                    email=self.recipient_email),
                    str(e)) from e
            languages = Lang.search([('code', '=', 'fr'),], limit=1)
            languages = set(languages)
            to = self._get_addresses(self.recipient_email)
        return to, languages

```

```auto
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of this repository contains the full 
     copyright notices and license terms. -->
<data>
    <xpath expr="//label[@name='recipients']" position="before">
        <label name="recipient_email"/>
        <field name="recipient_email"/>
        <newline/>
    </xpath>
</data>

```

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 27, 2024, 11:37am UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060/3 "2024-11-27T11:37:28Z")

</div>

It is not the first time that such request happens.  
So I think we could make the fallback user always visible.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [November 27, 2024, 2:10pm UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060/4 "2024-11-27T14:10:01Z")

</div>

> **[Always display fallback user in notification email form (#13705) · Issues ·...](https://foss.heptapod.net/tryton/tryton/-/issues/13705)**
>
> Following https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060. In some case, we just need to send all the notifications to the same user but fallback user is only visible...

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [November 28, 2024, 2:10pm UTC](https://discuss.tryton.org/t/notification-email-for-internal-emails-alias/8060/5 "2024-11-28T14:10:12Z")

</div>

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