Need advice on configuring email relay

Hello my fellow Linux people -

I’m looking for advice on setting up email routing from one 3rd party service to another. The first service is an external ticketing service and the second is an SMTP service.

Multiple clients contact us through the ticketing system. When they create tickets an email is generated and sent to them. Currently, the ticketing system connects to the 3rd party SMTP service and sends an email “On Behalf Of” a stock user on the ticket creators domain, but the actual “From: address” isn’t from their domain.

So - I would like to put a relay between the two and “route” the emails to the external email address in such a way that the “From” address shows the ticket requestor’s domain.

In other words, let’s say that there are 3 companies who use the ticketing system: @companyA.com, @companyB.com, and @compnayC.com. When a person from @companyA.com creates a ticket, it goes to the relay server, which then constructs and email with a “From:” address @companyA.com and sends it through the 3rd party SMTP service.

Ok - now that we got that out of the way, I’ll describe how the 3rd party SMTP service works. You’re able to ‘connect’ to the service through a single FQDN (smtp.emailService.com). You can send emails through it using python for example, by using the smtplib and providing a username and password and then sending an email you’ve constructed. The connection portion is very similar if you connect a script to smtp.gmail.com, however you can construct the headers/etc with this service.

Anyway, I think I can do this with postfix, but I’m not sure how to create the “personalized” email domains depending on the address postfix receives it from. Maybe there’s transport mapping I can do, but it seems like there’s gotta be some logic to do the mapping. Therefore, I was looking into how to create an SMTP relay with Python, and figure out how to do the logic from there.

Any advice on this?

Have you tried changing/setting the myorigin setting?

1 Like

On the ticketing system?

Wouldn’t hurt to test that and on the relay server

1 Like

Looking into myorigin on postfix.

Alright - here’s what I’m thinking about trying.

Setup a postfix relay server. Then, using stunnel, setup several smtp connection between local ports and the fdqn of the smtp service for each domain.

Then, I’ll configure the relaymap so that each domain maps to a localhost stunnel port (which connects to the smtp service). Lastly, I’ll setup the sasl_passwd file and then harden the thing, as to help us all out by not creating an open relay.

We’ll see how this goes por la manana.