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?
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”.
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.
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.