Currently I am managing mailboxes with cPanel. I configured the mailboxes in cPanel, to pipe the emails to a PHP script. I am using cPanel only for that purpose, so I wanna get rid of all that gear.
All I need is:
These PHP extensions rely on preexistant email server and account, so, these alone are not enough.
From what I have been researching, apparently I need to do it throught PHP command line, with CLI or CGI, not sure which one.
I work in a VPS with LAMP CentOS, maybe there is a open source PHP application or library that can be implemented here, just for the specific task.
Sorry to say so, but what you plan to do does not make any sense at all.
Reasons:
To be able to receive and access emails you'd have to implement at least one fully fledged networking server: an SMTP server to receive and either additional servers for accessing the mailbox, like an IMAP4 server or similar. Plus all the overhead for ssl or tls encryption, authentication, and and and...
Please don't get this wrong, but my impression is that you did not yet fully understand how email exchange actually works and what is required for that.
Instead I would suggest that you work into this field by getting hold of some standalone system you can work with, maybe a virtual private server you rent including a domain name and a static IP address. Note that some webspace with php is not enough for this. Then you install the typical packages, some Linux operating system, maybe the Postfix SMTP server, the Dovecot IMAP server and everything that is required by them. Then you configure that stuff and if you really succeed and are able to actually receive messages by that setup, then is the time to come back to this question. I'd expect two things: