How do I configure Postfix and Nginx with multiple domains/hostnames?

June 10, 2015 1.3k views
PHP Email Nginx Ubuntu

Okey so as the title suggests, I am trying to configure Postfix to work with multiple domains.

When I use the PHP mail() function on my website I want postfix to use the hostname of the current Virtual host (server { } ).

For an example:

I have 2 domains, and

Postfix variable "myhostname" is set to because the hostname can't be both and

On I am trying to use the PHP mail() function to send an email to my CRM. The CRM has only whitelisted the hostname so it disallows the email from being received.

So I thought this might be possible in Nginx, to change the "myhostname"-variable depending on which Virtual host PHP is sending emails on.

If this is not possible I would love to hear other suggestions to get my example above to work, this problem is driving me insane.

With love,

Be the first one to answer this question.