I currently have two domains set on my server on two different IPs. One is set on the domain's primary IP, and the second on a failover IP. Let's say I have domain1.com and domain2.com

Currently, the mailer daemon delivers from MAILER-DAEMON@domain2.com, originally, postfix was setup with domain2. I would like it to send from domain1 instead. I have no idea what makes postfix select domain2 over domain1.

I've seen Rename mailer-daemon in postfix on the issue, but I don't want to "rename" mailer-daemon, I want to change the domain mailer-daemon is using by default.

  • you can try with @backupmx relayhost = primarymx this garantee that regardless which my you get Mail in it will always be sent from pmx, remind to setup the mx records that it will respobd like this – djdomi Aug 12 '19 at 16:07
  • Possible duplicate of Configuring a Postfix backup server – djdomi Aug 12 '19 at 16:10

You probably have your original domain in $mydomain, so change that.

From the Postfix Basic Configuration:

What domain name to use in outbound mail

The myorigin parameter specifies the domain that appears in mail that is posted on this machine. The default is to use the local machine name, $myhostname, which defaults to the name of the machine. Unless you are running a really small site, you probably want to change that into $mydomain, which defaults to the parent domain of the machine name.

For the sake of consistency between sender and recipient addresses, myorigin also specifies the domain name that is appended to an unqualified recipient address.

Examples (specify only one of the following):


myorigin = $myhostname (default: send mail as "user@$myhostname")
myorigin = $mydomain   (probably desirable: "user@$mydomain")

You need to have 2 proper lines in your main.cf file (/etc/postfix/main.cf):

  • mydomain = mydomain1.net (while mydomain1.net is your domain)

  • myorigin = $mydomain

The hostname part is usable for the MX part:

  • myhostname = mx.mydomain1.net (which will give you the hostname and )
  • myorigin = $myhostname

If main.cf file has myorigin = /etc/mailname then $myorigin is set to the domain name in the file. To change the domain name just change the domain in the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.