0

I have a Google Workspace account that has multiple sites running on one user. I have aliases setup for gmail.

I've setup a Google Workspace SMTP Relay to send emails from my linux server for systems like Wordpress using postfix.

It works fine with postfix and emails get sent. However, the problem is that all emails are being mailed by the default domain of the Google Workspace account, because the myorigin setting points to it, e.g default.com.

Here are my postfix/main.cf settings:

myorigin = /etc/mailname
mydestination =  localhost
relayhost = [smtp-relay.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

In the file /etc/mailname, default.com is the entry. If I change it to say domain-2.com then emails will be sent from domain-2.com. But all my sites will also send emails from domain-2.com.

What I want to happen is for every email to be mailed by the appropriate domain. So if domain-3's Wordpress sends an email I want it to be mailed by domain-3.com rather than domain-2.com or whatever is in /etc/mailname

Adding multiple domains to the /etc/mailname file doesn't seem to work.

I also tried

myorigin = localhost
myorigin = localdomain
myorigin = localhost.localdomain
myorigin = local.domain

How can I accomplish this?

chroncile
  • 1
  • 1
  • 1
    The mail client needs to set the from address correctly. I don't think WordPress bothers to try to set it at all. Maybe there is a plugin that helps with that. The envelope sender which you're messing with here really doesn't matter; that should always be the FQDN of the machine sending the mail, and does not need to have any relation to any of the domains in the messages you send. – Michael Hampton Jan 22 '21 at 03:05
  • The from address is correctly set to the appropriate domain. However, it is being mailed by the domain listed in /etc/mailname. So for Wordpress it correctly sets the from address as wordpress@domain-2.com, but it's still mailed by default.com. The return path and X-Relaying-Domain parameters are set to default.com rather than domain-2.com. If I set /etc/mailname to domain-2.com then both these parameters get set to domain-2.com. I've setup DKIM, DMARC and SPF, but emails are still ending up in spam even though they pass. – chroncile Jan 22 '21 at 04:14

0 Answers0