I am trying to send email via my web server using PHP but for some reason the email never arrives. According to PHP the email was sucessfully sent but I never receive the email. I know its not a spam problem as the web server used to be able to successfully send email until I reinstalled it last week. It has been installed with exactly the same OS and configuration except now it doesn't work.

It is using the default PHP settings for sending email and I have enabled SMTP in the firewall but this doesn't seem to be working.

Are there any logs for the PHP email sending that may be able to help me trouble shoot why it isn't working?


PHP is probably trying to talk to a local SMTP server, that is, one running on the same machine as the web server. So, have you set one up? There are many to choose from. The most popular are Sendmail, Exim, Postfix, and Qmail.

Try sending email using the primitive mailx client. If it can't send mail outside the machine, it's probably for the same reason PHP can't, so the problem would therefore lie outside PHP.

Try sending email by hand from the command line by telnetting to localhost on port 25 and speaking the SMTP by hand. There are many guides for this online. Here's one. Where you go from there depends on what happened:

  • If you get no answer on port 25, there is no SMTP server running.

  • If it answers, maybe it will give an error message that clues you in to the problem.

  • If it appears to accept the email, you have to go about debugging your local SMTP server.

  • Thanks for your help, I've tried sending the email via telnet and when I send the message it displays the message 250 2.0.0 Ok: queued as 6B32C28B7D does this mean it thinks it has worked or is the server just queing and not actually sending. If it is queing what would make it not send. Thanks for your help – Boardy May 4 '12 at 21:29
  • you should check the mail queue to see if it has actually set... but doing that depends a lot on your mail server. Also you should check your mail logs. – xenoterracide May 4 '12 at 21:43
  • I've now tried reinstalling the server and I get the same message when I send the mail through telnet. I then run mailq to view the queue and it says mail queue is empty – Boardy May 4 '12 at 22:03
  • @Boardy: Then xenoterracide is right: you should check your mail server's logs. – Warren Young May 4 '12 at 22:05
  • Is there any particular logs, sorry I'm fairly new to linux – Boardy May 4 '12 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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