Change Postfix settings.. but for only one website?

SYSTEM INFORMATION
OS type and version Debian 10
Virtualmin version Latest

We are hosting about 70 websites on our current Virtualmin server and are using Postfix → SendGrid to forward emails.

We are going to add a large new website on the server. The problem is that this website needs to use a separate Sendgrid account.

We could change this line in the Postfix config, but it would change for all websites:
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

Is there a way to change it only for a specific website? Any ideas on how we could do this? We could use a different PHP version if that would be any help?

you could try running 2 instances of postfix and change what you need read here for further info

Two instances of Postfix would enable you to do what you want @Etienne, as @jimr1 has suggested.

However, if you want to use one instance of Postfix to use one Sendgrid account for n number of domains in Virtualmin and another Sendgrid account of a specific virtual server in Virtualmin then you should look up “sender dependent relay host”.

PHP version has nothing to do with it.

You can configure Postfix with a sender-dependent relayhost map (option is sender_dependent_relayhost_maps).

Or, you can just configure your app(s) to use the relay. That’s what I do. My regular admin mail goes through Postfix, but my apps (WordPress and Discourse for this forum) use a relay (Mailgun, in my case). Most PHP mailer libraries and APIs make it easy to configure how you send mail.

Running a separate postfix instance is overkill and would be a lot of annoyance for no value.

Thanks everyone for your input, VERY appreciated.

Using the “Sender dependent relay host” seems to be the most logical thing to do for my setup.

I am confused because both relay use Sendgrid. The transport mapping /etc/postfix/dependent will look like this:

bigwebsite.com	[smtp.sendgrid.com]:2525
*       		[smtp.sendgrid.com]:2525 //Probably wont I need this line since it's setup in main.cf

Since both relay will use Sendgrid, but a different account, the /etc/postfix/sasl_password will look like this:

[smtp.sendgrid.net]:2525     apikey:APIKEY_1
[smtp.sendgrid.net]:2525     apikey:APIKEY_2

Since the left column is identical, Postfix won’t know which APIKEY to use for it credential?

I am missing something?

You could list only the domain that is the exception - all other domains which use Sendgrid could continue with your current configuration. There is no need to list them in the map.

Maybe this? How can I get postfix to send mail to different relay hosts? - Server Fault

I haven’t tried it, but it seems to be the same basic problem.

My /etc/postfix/sasl_passwd was wrong, it should be:

bigwebsite.com               apikey:APIKEY_2
[smtp.sendgrid.net]:2525     apikey:APIKEY_1

Thank you so much guys!

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