# Sending email for two different domains

**URL:** <https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429>\
**Category:** System Administrator\
**Created:** [August 11, 2023, 10:59am UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429 "2023-08-11T10:59:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [August 11, 2023, 10:59am UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/1 "2023-08-11T10:59:10Z")

</div>

Hi,

We have two web\_shops on the same database each selling a different sets of products.  
Sales of each web\_shop are imported to tryton to generate shipments and invoices.  
For each web\_shop, we have a different set of reports with the branding of each domain.

We will like to setup automatic delivery of such reports to the customer using [notification email](https://docs.tryton.org/projects/modules-notification-email/en/latest/) module. We have two different SMTP credentials to access each domain but I see only a single configuration for email uri.

How can we setup two different smtp servers for notifications?

---

<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:** [August 11, 2023, 11:30am UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/2 "2023-08-11T11:30:44Z")

</div>

You can use the same SMTP server to send email from 2 different domains.  
The notification email module allows you to define the `From` for each notification.  
One improvement could be to permit to use more domain in `set_from_header` than just the sender domain. But for now you can use a generic sender and two different `From`.

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [August 11, 2023, 12:15pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/3 "2023-08-11T12:15:50Z")

</div>

> [@ced](#):
>
> You can use the same SMTP server to send email from 2 different domains.

I guess you are propsing to setup a local smtp server which relays mails to multiple domains as described here:

> **[Configuring Postfix for Multi-Domain Mail Relay](https://medium.com/geekculture/configuring-postfix-for-multi-domain-mail-relay-d33cd236298a)**
>
> Hosting a multi-domain email environment with Postfix is relatively simple. Well, as simple as hosting email can be… Setup virtual…

Am I right?

---

<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:** [August 11, 2023, 12:37pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/4 "2023-08-11T12:37:39Z")

</div>

Not necessary, there is no need for a relay to send from a server using two different domains.

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [August 11, 2023, 12:38pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/5 "2023-08-11T12:38:36Z")

</div>

Main problem is that we do not control the servers sending the emails.We just have the credentials to conect to them.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [August 11, 2023, 1:08pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/6 "2023-08-11T13:08:40Z")

</div>

So you have two servers (bare metal, VM etc), and each is sending email for just one domain? I’m struggling if it is worth the time and effort to implement such thing in Tryton or just spin up a container with `postfix` which can handle multiple domains. It’s very easy to setup and can be easily extended with more domains. You just send the email to `postfix` and it will deliver it to the right mail server based on the domain part of your email.

Edit:  
It’s an old article [Setup Postfix to Relay Mail for Specific Domains or Users - Mad9Scientist.com](https://mad9scientist.com/postfix-relay-mail-specific-domains/) but it shows how easy it is. The only thing it is missing, is the login part (`sasl_passwd`) with the mail servers you don’t control.

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [August 11, 2023, 5:09pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/7 "2023-08-11T17:09:14Z")

</div>

> [@edbo](#):
>
> So you have two servers (bare metal, VM etc), and each is sending email for just one domain?

No, we have a single tryton instance managing two web shops with each different domains.  
Each domain has its own stmp server which is externally managed.

So I need to send the notification for each web shop using each SMTP server, username and password.

---

<div class="post-metadata">

**Author:** ![albert](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/albert/32/21_2.png) [@albert](https://discuss.tryton.org/u/albert)\
**Post date:** [August 11, 2023, 5:24pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/8 "2023-08-11T17:24:17Z")

</div>

> [@pokoli](#):
>
> No, we have a single tryton instance managing two web shops with each different domains.  
> Each domain has its own stmp server which is externally managed.
> 
> So I need to send the notification for each web shop using each SMTP server, username and password.

You can configure Amazon AWS SES or any similar service and send e-mails for as many domains as you wish with just one set of credentials.

The manager of the domain will only need to add some entries to their DNS server.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [August 11, 2023, 6:17pm UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/9 "2023-08-11T18:17:03Z")

</div>

> [@pokoli](#):
>
> No, we have a single tryton instance managing two web shops with each different domains.  
> Each domain has its own stmp server which is externally managed.
> 
> So I need to send the notification for each web shop using each SMTP server, username and password.

Just drop a `postfix` mailserver in between. Your Tryton instance is sending the mail to `postfix` with the right `From` address. Postfix will then send the email to the right smtp server based on the domain of your `From` address. When you run Tryton on a Unix/Linux, chances are high that `postfix` already is installed. Just some configuration is needed.

---

<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 6, 2024, 7:44am UTC](https://discuss.tryton.org/t/sending-email-for-two-different-domains/6429/11 "2024-11-06T07:44:50Z")

</div>

> [@edbo](#):
>
> Just drop a `postfix` mailserver in between.

> [@karrygordon](#):
>
> using a custom module that allowed for multiple SMTP configurations

[OpenSMTPD](https://opensmtpd.org/) is probably the simplest solution.
