# Different relay hosts on Mautic + Postfix!

**URL:** <https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284>\
**Category:** Product Support\
**Created:** [March 8, 2020, 1:18am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284 "2020-03-08T01:18:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [March 8, 2020, 1:18am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/1 "2020-03-08T01:18:43Z")

</div>

Hi!

I have a digitalocean server, with Mautic and Postfix configured.

I use multiple domains on my emails like @domain1, @domain2, @domain3.

For each domain, I have configured postfix (sender\_dependent\_relayhost\_maps) to use a different relayhost.

When sending manually , if sender is x@domain1 it will go to relay.domain1  
If sender is a@domain2 it will go to relayhost relay.domain2

Tried to connect manually using telnet localhost 25, and it will work always.

So, I configured Mautic to use ´Other Mail Server´, ´localhost´ , ´25´.

Mautic is sending emails ok (from every campaign), but it will only use the default relayhost, even from user x@domain1 for example

Looks likes some header is different.

Can anybody help?

PS: On console, I did

sendmail -f osvaldo@domain1 -t \<\<EOF  
To: [mypersonalmail@gmail.com](mailto:mypersonalmail@gmail.com)  
Subject: Hey, testing  
Content-type: text/html

**Isn’t this awesome?**  
EOF

And it goes ok, via the correct domain1 relay.

PS2: I need this, because if I send from email@domain1 and it gets delivery by mx.domain2, the email has a higher chance of getting marked as spam.

Thank you!

---

<div class="post-metadata">

**Author:** ![julien66](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/julien66/32/1033_2.png) [@julien66](https://forum.mautic.org/u/julien66)\
**Post date:** [April 3, 2020, 2:58am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/2 "2020-04-03T02:58:41Z")

</div>

@ojaneri were you able to make that work?

Did you run postmap on the relayhosts\_map file?

Please take a look at this blog post that shows details well.

---

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [April 3, 2020, 3:23am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/3 "2020-04-03T03:23:38Z")

</div>

Hi. I did run postmap on relayhosts\_map, but no success. Tried everything I could remember, but nothing.

About the article, can you post the link? didnt appear for me. Thanks!

---

<div class="post-metadata">

**Author:** ![julien66](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/julien66/32/1033_2.png) [@julien66](https://forum.mautic.org/u/julien66)\
**Post date:** [April 3, 2020, 8:20pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/4 "2020-04-03T20:20:45Z")

</div>

Oh sorry I forgot the link:

> **[Postfix sender\_dependent\_relayhost\_maps](https://tapoueh.org/blog/2010/09/postfix-sender_dependent_relayhost_maps/)**
>
> The previous article about M-x mailq has raised several mails asking me details about the Postfix setup I’m talking about. The problem we’re trying to solve is having a local MTA to send mails, so that any old-style Unix tool just works, instead of...

Isn’t the issue du to the fact that Mautic uses only 1 mailbox for sending the emails. So postfix does its job properly because the sender is always the same. Mautic only adds some headers for the other users, but send using always the same mailbox. (I’m not 100% sure about what I’m suggesting since I’m quite new to Mautic but it’s my current understanding of how it works)

Please let me know if you find a way to make it work

---

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [April 11, 2020, 2:12am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/5 "2020-04-11T02:12:56Z")

</div>

Yes, you nailed down. It uses the same inbox to send, only add +NUMBER to username so it can track bounces.

Still trying to find some workaround…Thank you

---

<div class="post-metadata">

**Author:** ![julien66](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/julien66/32/1033_2.png) [@julien66](https://forum.mautic.org/u/julien66)\
**Post date:** [April 13, 2020, 8:41pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/6 "2020-04-13T20:41:31Z")

</div>

@ojaneri there’s this plugin where you can specify multiple mailboxes:

> **[mtcextendee/mautic-random-smtp-bundle](https://github.com/mtcextendee/mautic-random-smtp-bundle)**
>
> Random SMTP server support for Mautic. Contribute to mtcextendee/mautic-random-smtp-bundle development by creating an account on GitHub.

The issue is the selection is random, you lack good control. But still that might solve your issue?

---

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [April 13, 2020, 9:52pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/7 "2020-04-13T21:52:03Z")

</div>

Thank you for your reply, but I wont help, because I use different SMTP host based on sender. I have 4 domains on same mautic installation ☹

The only solution is to have 4 different mautic installation, each one with only one domain configured and the correct smtp. But I dont want to go that route, and have to admin 4 mautic´s installs instead of one (and because I use email templates and campaigns between them)

---

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [April 13, 2020, 9:55pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/8 "2020-04-13T21:55:13Z")

</div>

But this plugin can be modified to use the SMTP Server basead on the domain of the sender…if my programming wasnt too rusted I would try.

Just add a new field on the csv of the smtp relay configuration to be the sender domain, and change the code instead of suffle() pickup the right smtp relay for that sender.

---

<div class="post-metadata">

**Author:** ![julien66](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/julien66/32/1033_2.png) [@julien66](https://forum.mautic.org/u/julien66)\
**Post date:** [April 16, 2020, 5:39pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/9 "2020-04-16T17:39:55Z")

</div>

OK I see. I was supposing something like that: that this plugin could be modified to handle this use case.

I’d like to set up Mautic this way as well, to be able to manage multiple domains, but not well versed in PHP. Quite a strong limitation that Mautic only allows 1 domain.

---

<div class="post-metadata">

**Author:** ![ojaneri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ojaneri/32/1921_2.png) [@ojaneri](https://forum.mautic.org/u/ojaneri)\
**Post date:** [April 16, 2020, 8:57pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/10 "2020-04-16T20:57:15Z")

</div>

So, we need a way to change the headers of the Sender email to the same Sender configured on email template, instead of bounce+991919@domain.

Anyone more knowledgeable with Mautic source?

Thanks! (:

---

<div class="post-metadata">

**Author:** ![ericf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ericf/32/1669_2.png) [@ericf](https://forum.mautic.org/u/ericf)\
**Post date:** [March 12, 2021, 7:57pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/11 "2021-03-12T19:57:13Z")

</div>

I’m interested too :  
Being able to choose the SMTP server based on sender (~ owner) would be a very useful feature.  
**edit** : Based on campaign would be even better ! @dimitri 😉

---

<div class="post-metadata">

**Author:** ![dimitri](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dimitri/32/4437_2.png) [@dimitri](https://forum.mautic.org/u/dimitri)\
**Post date:** [March 12, 2021, 11:29pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/12 "2021-03-12T23:29:53Z")

</div>

It would be very nice to have several SMTP servers, and being able to select one on the campaign level.

---

<div class="post-metadata">

**Author:** ![vega4](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/vega4/32/7308_2.png) [@vega4](https://forum.mautic.org/u/vega4)\
**Post date:** [June 20, 2022, 9:31am UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/13 "2022-06-20T09:31:08Z")

</div>

yes that’s definitely needed. Currently mautic works against us for similar cases in every possible way.

1. external-domain FROM emails are IGNORED
2. no way to override the Mautic messing up with the FROM address (appending ‘+\_XYZ’)

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [June 20, 2022, 12:21pm UTC](https://forum.mautic.org/t/different-relay-hosts-on-mautic-postfix/13284/14 "2022-06-20T12:21:58Z")

</div>

Yeah, Matic is not for everyone.  
I suggest you try Mailwizz. Seems, that tool would work for you lot better then Mautic.  
Multi SMTP server, you can even rotate them, weighted, etc. All you need to do you thing.
