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?

link|improve this 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 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 at 2:26
feedback

migrated from stackoverflow.com Jan 12 at 12:39

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

closed as exact duplicate by mailq, splattne Jan 13 at 11:16

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

1 Answer

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.

link|improve this answer
feedback

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