Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a quick question. How do I setup postfix to send an email to another server (Exchange Server) when sending to an email address that has a sub-domain of our main server. For example, say our main server is mail.example.com and we have a Exchange server setup to receive emails from exchange.example.com. We have the MX records setup in our DNS and it receives correctly if we send from a GMail account. However, when we try to send an email from a @example.com account we get the following error:

Host or domain name not found. Name service error for name=exchange.example.com type=A: Host not found

I believe Postfix checks for local mailboxes first and if its setup with the domain it delivers to the local account, but in this case the sub-domain accounts are located in another server. Anyone have any thoughts on what I need to do within Postfix so it doesn't look locally for the exchange.example.com mailboxes?

I found relay_domains directive within Postfix but that doesn't seem to fix it when I add the sub-domain.

Thanks for your help.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

It seems that you're trying to set up an SMTP gateway, and do not want to expose your Exchange Server to the "outside" network, right? Because usually I'd just set up the appropiate MX records for the domain.

Postfix, by design, won't accept mails for foreign domains, but postfix wouldn't be postfix if it wouldn't be possible. It just requires you to do a bit more work, for example, telling postfix which email-adresses are valid (it can't determine this by itself for a subdomain, naturally). It's well explained over here: http://www.knowplace.org/pages/howtos/smtp_gateway_for_multiple_domains_with_postfix.php

share|improve this answer
    
We do have MX records setup and no it doesn't have to be hidden from the outside world. The issue isn't accepting emails from foreign domains. We are trying to send an email from user@example.com to user@exchange.example.com but the email is never getting to the exchange.example.com server. So, the example.com server doesn't know where exchange.example.com is located. I think its looking locally in which it should not. Again, the MX records are setup and we can successfully send an email to the user@exchange.example.com from an outside address (i.e Gmail) –  thiesdiggity Nov 28 '11 at 16:58

The error seems to indicate that exchange.example.com does not exist in DNS. In order for postfix to find the exchange server, it has to be able to resolve the exchange.example.com domain name to an ip address, so it knows where to route it.

share|improve this answer
    
Thanks for the speedy reply. But it doesn't make sense that if we send an email from a GMail account it routes correctly. Why would it work from an outside email address rather than an internal one? Shouldn't postfix look at the MX records and not an A record? –  thiesdiggity Nov 28 '11 at 16:40
    
As per the SMTP RFCs, if no MX record is found but an A record exists, the A record will be used. –  adaptr Nov 28 '11 at 16:42
    
Do you have internal DNS that is separate from your external DNS zones? It's possible it exists on the outside but not the inside. Check both the MX and A records if there's an internal zone; if postfix can't find a proper MX record for exchange.example.com, it'll default to trying to hit the A record for exchange.example.com, and if that doesn't exist then that'd be my guess as to why this error surfaces. –  Peter Grace Nov 28 '11 at 16:43

relay-domains is indeed the correct parameter, but it is not all you need to do.
Run postconf parent_domain_matches_subdomains and check if relay_domains is present; if it is, add the line to main.cf and remove relay_domains from the list (or unset the option entirely, but make sure you understand the consequences.)

share|improve this answer
    
Thanks adaptr for the suggestion, I just ran that command and the output was: parent_domain_matches_subdomains = debug_peer_list,fast_flush_domains,mynetwork ,permit_mx_backup_networks,qmqpd_authorized_clients,smtpd_access_mapsNot sure what to do next since relay_domains is not in the list. Any thoughts? Thx. –  thiesdiggity Nov 28 '11 at 23:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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