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

The PHP mail function I am using does not work completely. It will sent mails to GMail easy enough. However, emails routed directly to my internally hosted exchange server are not getting through.

The servers/domains are setup is as follows.

URLs are registered with Network solutions ( &

NS directs all traffic to our ISP ( Socket directs as follows:

  • Mail to our local server
  • FTP to our local server
  • HTTP to our website hosted on

Also, emails originate outside server sitting at chihost. That is where the PHP executes.

Traffic to our local server goes through a Watchguard firewall which routes mail traffic to our locally hosted Exchange server.

Is there some reason why exchange won't accept these emails?

share|improve this question
up vote 1 down vote accepted

Is the server with PHP Linux or Windows based? For now I'll assume it's Linux based. Some of the advice below is valid regardless, you just have to take a slightly different approach.

First thing to do is determine if the emails are even reaching your Exchange server. When you ping the domain, are you getting the IP address you expect?

The outgoing email should have a "Return-Path" header. If the email is being rejected by Exchange, you should get a response to the address in "Return-Path" stating why the email was rejected. Typically with sendmail bounce backs end up in /var/mail.

With PHP's mail function, there are a couple things to keep in mind. Are you setting a "From:" header? Is the address reachable? If you are setting headers (should at least set From:) make sure you don't have any trailing lines after your headers. Some mail server's don't like this.

Last thing to check is the outgoing ip address in the email headers. Sometimes sendmail puts instead of the public ip address. This has caused issues for me in the past. Since sendmail was difficult to configure, I just ended up using postfix.

Another thing to consider is instead of sending mail from the local server on the PHP box, you could try configuring PHP to use your Exchange server to send emails.

share|improve this answer

Your Answer


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.