6

I would like to set up an mail server on one of my hosted machines that only supports PHP. There is no standard mail server running on that machine.

Are there any mail servers written in PHP? Or, is it even possible to write a mail server in PHP in regards to the limitations of the language?

mafu
  • 2,855

2 Answers2

4

Your fundamental problem is going to be that even if you wrote or found a mail server implemented in PHP, you're not going to be able to run it on your host.

  • The web server executing your PHP scripts is listening on port 80 (and maybe 443), not 25, 587, or 465.
  • The scripts will get terminated by the web server after running too long or using too much RAM.
  • You're not going to be able to run the script as a service on the host.
  • Even if you could, most will have resource monitors that kill long-running scripts.
  • Even if that weren't an issue, root privileges are normally required to listen on low-numbered (< 1024) ports.

Edit: All of the above assume shared hosting. Of course, most of these constraints go away with a VPS. However, in that case you can install proper mail servers so it doesn't really matter anyway.

Beyond all that, there's no particular reason that nobody's bothered writing a mail server in PHP, it's just that it's not a particularly useful endeavor.

@Linker3000 has it right in @Ignacio's answer: Move to a host that gives you what you want.

afrazier
  • 23,505
3

It is theoretically possible, but no one does it since a mail server is a large, complex beast and there are already so many available written in other languages