Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
postfix: force server to send mail outside of localhost

I have full control over a virtual dedicated server. The problem is the mail server resides elsewhere. I have a problem that when sending mail via php's mail function if the address shares the same domain name as the webserver it looks at the localhost, doesn't find the address, and rejects it. How can I configure my system to look outside for the mail server? Is this a hosts issue?

share|improve this question

migrated from Jan 12 '12 at 12:39

This question came from our site for professional and enthusiast programmers.

marked as duplicate by mailq, splattne Jan 13 '12 at 11:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Huh? If "the address shares the same domain name as the web server" ... then that's where it should be delivered. \ is not \ – Brian Roach Jan 11 '12 at 23:04
I think you misunderstand. This is email server vs. web server. Emails at go to a different server than the webserver that hosts the website for The problem is postfix, which handles the routing of mail sent via php won't look outside the localhost. It just sees that is registerred on the webserver so it won't try to route mail messages to that domain to another server. I need to figure out how to tell postfix to route all mail out. – LoneWolfPR Jan 12 '12 at 2:26

You will need to configure the MTA (Mail Transfer Agent, for example Postfix, Sendmail or Exim4) to always relay mail and not be the final destination for any letter. This is done differently on each of those systems.

For Postfix, check out the mydestination directive. It usually defaults to $myhostname. Either change myhostname to the machines fully-qualified domain name (as required by the SMTP standard) or at least remove the hostname from mydestination.

Setting the FQDN of the machine to the name of the website (e.g., is actually wrong, or at least confusing, when you want e-mails for to be delivered elsewhere. In that case the FQDN of the machine can be and then also point the additional (not fully-qualified) domain to the same IP address.

share|improve this answer

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