I'm going to go way, way out on a limb here and act as if this is not a troll.
Checking for pending mail has NOTHING to do with PHP, unless you intend to write a Web-based mail client, and I have no idea why you would want to do such a thing.
This is a system/desktop-specific issue and the problem was solved years ago. Every Unix/Linux system ships with the necessary tools (biff, Xbiff, Knewmail, gbiff, etc.). The standard free Windows mail tools will beep and show an icon in the systray if you bave new mail. A Macintosh can be trained to read the mail aloud when incoming mail arrives. Use the tools that are already at your fingertips.