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.

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 stackoverflow.com 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. \@www.foo.com is not \@foo.com –  Brian Roach Jan 11 '12 at 23:04
    
I think you misunderstand. This is email server vs. web server. Emails at mydomain.com go to a different server than the webserver that hosts the website for mydomain.com. The problem is postfix, which handles the routing of mail sent via php won't look outside the localhost. It just sees that mydomain.com 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

1 Answer 1

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., example.com) is actually wrong, or at least confusing, when you want e-mails for @example.com to be delivered elsewhere. In that case the FQDN of the machine can be somename.example.com and then also point the additional (not fully-qualified) domain example.com 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.