Receive mail using PHP

I am looking for a code to receive mail using PHP. So please help me.

I have checked many codes online and didt find nothing works perfect.

PHP is a web scripting language, not a mail client. You can built a mail client with PHP, or use a mail client on your server to redirect emails to a PHP script, but PHP cannot just receive mail.

As storm rider has already pointed out you will need a mailserver to ‘collect’ your mail. However once you have the mail sitting on a mail server you can use PHP to access that mail, parse it and then do other things with the information.

Check out PHPs IMAP function in the manual