As mentioned, PHP *can* and always has had the ability to do this (for sure since 4, can't remember what <= 3 provided for socketing, but that's a pretty trivial fundamental of a web based language I'd say). That would be writing a simple socket app. The real question would be why bother? There are many many other languages far more suited to this job than PHP is (even perl comes to mind here).
So short answer, sure PHP has always been able to do this, but that doesn't really make it a great idea. You wouldn't run this in a web environment either, rather you would simply set up listeners on the pop and imap sockets. Mail comes in, PHP would do something with it, and away you go.
header('HTTP/1.1 420 Enhance Your Calm');