How to make Postfix relay mail to the servers specified as MX, not to itself

Posted on 2007-10-09
Medium Priority
Last Modified: 2008-01-09

I have a machine with Postfix that I want to use for one of my scripts to send mail, to the same domain. It's kind of confusing for me, but here it is:

Let's say the machine name is mydomain.com.mx, and the MX entries of the domain are setup for Google Apps (so Google handles all my mail).

So, currently if I try to send mail from inside the machine, I get a 'user not found' error from postfix, since it tries to deliver mail locally, instead of using the servers specified in the DNS.

Is there an easy way to fix this?

Question by:ivanvega
  • 2
  • 2
LVL 30

Accepted Solution

Kerem ERSOY earned 1500 total points
ID: 20045048
It is very easy you can add this command:
edit your main.cf
add this command:
relayhost = Your_mx_host_name

save & exit. Then restart your postfix:

# postfix reload

and that is it.

If you wanto to relay only your domain to another server then change
/etc/postfix/virtual and add this line to this file:
@mydomain.mx        @relay_host_name

save & exit. Then you need to create the binary file with these commands:
# cd /etc/postfix
# postmap virtual

Don't forget to restart your postfix:
# postfix reload


Author Comment

ID: 20045105

I tried your first suggestion and it still doesn't work:

"Recipient address rejected: User unknown in local recipient table"

And my system doesn't have a /etc/postfix/virtual file.


Author Comment

ID: 20045151
It seems if I change myhostname and mydomain too (nullclient.mydomain.com.mx, mydomain.com.mx), it now works.

relayhost also accepts the actual domain, instead of a given MX host, and then it will select the right MX entry. Nice.

LVL 30

Expert Comment

by:Kerem ERSOY
ID: 20045312
ok. Don't forget to modify your /etc/hosts too. Remove your hostname as an alias to localhost add its own address such as:             localhost.localdomain localhost
<ip_of_your_ethernet>      nullhost.mydomain.mx   nullhost

save & exit.

You can just create /etc/postfix/virtual if it does not exist. But in the default  configuration there exists a virtual file with lots of commensts. It is possible that your default config is not in /etc/postfix. if it is just create yourself. it is a text file afterall..

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
In this video we show how to create a User Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Mailb…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question