Domain – Sending mail with Postfix from multiple domains on the same server

domainpostfix

I have a dedicated server with multiple Ruby on Rails apps on it. Each of these apps run on their own domain. When configuring Postfix there are parameters called "myhostname" and "mydomain". As far as I can see they accept one domain only and when sending mails from my apps, the domain in this field indeed states this as the sending server (in the raw gmail email for example) no matter what the "From" tag in the email says. Ideally I want domain2.com to be the sending server if I send mail from info@domain2.com, even if domain1.com is the "mydomain". My questions are:

  • Can I change the sending server according to the email actually used when sending?
  • Is this a big deal, and how do others solve this issue?

I only use Postfix on this server for sending e-mails, not receiving. Grateful for any suggestions.

Thank you

Best Answer

As you accept all mails from 'mynetworks' (by default), this does not affect the sending side (Have a look at where permit_mynetworks is included). If the sender is not in mynetworks, you should do authentication, to trigger permit_sasl_authenticated and let the mails through.

For the receiving side, list your domains in mydestination.