Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to wrap my hear around how I am going to get around this latest hurdle. What needs to happen: PHP script sends email to our Exchange Server ....

Sounds simple right? Well the issue is that the LAMP server that has the PHP script on it is located in our office building, while our web server is hosted at a dedicated hosting company IP When we send the email to our exchange server (hosted by Office 365) from the office based PHP script IP, the exchange server pings-back the domain that the email came from only to find that the IP the domain resolves to is our web server IP ... and not the office (which the email originated from) It compares, they don't match .. and trash goes the email.

What methods can I use to get that email sent out with the IP so that the exchange server doesn't block it? I was thinking possibly having PHP SSH into the web server and use it's (the web server's) sendmail? Or do I remove sendmail on the office maching and use postfix to TLS into our exchange account? I have never dealt with this. ANY help, advice, web articles -- anything that points me to a viable solution would be appreciated!

share|improve this question
And which Office 365 service do you have? – Michael Hampton Jan 9 '13 at 1:44
We have the $4 per person Exchange Service -- – Zak Jan 9 '13 at 16:04
Really? If you are going to vote my question down, at least have the decency to comment about the downvote so that I can improve my question. it's easy to hit a check box, but so hard to type a message? Should be a requirement on stack sites ... – Zak Jan 9 '13 at 16:13

2 Answers 2

up vote 1 down vote accepted

Office 365 has a feature where it can act as a relay for your internal office mail servers, but it's only available on the enterprise plans ($8/user and up).

Your best bet here, assuming you don't want to spend a lot more money, is to create a user account ($4) and have your local mail server(s) authenticate to it. Sendmail and postfix are both capable of authenticating to a remote SMTP smart host.

share|improve this answer
Is Sendmail able to authenticate using TLS? I believe that is the authentication used by Office 365. – Zak Jan 9 '13 at 16:12
I have looked -- For future reference, and those it can help, Office 365 is TLS on port 587. Sendmail is able to communicate this way through SMTP. @Michael's method is the best solution if you don't want to spend the money. – Zak Jan 9 '13 at 16:40

Okay, so you're saying that your mail exchange server is doing a reverse DNS check and rejecting the email because that fails, right?

I recently had a problem where I was sending emails out via PHP and sendmail and the emails were going in the spambox due to reverse DNS failure as well. For me, the solution was setting a SPF (Sender Policy Framework) record that essentially told the receiving mail server "hey, this IP is actually authorized to do this!"

I am by no means an expert, but you may want to look in that direction. There are also a couple of other things that mail servers may check to validate the sender of the email, but I know less about those because the SPF method worked for me with both gmail and yahoo and that's all that I needed.

And if I turn out to be totally wrong, I hope somebody tells me so!

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.