Getting email from off-site providers?

I would like to know if it is possible for me to get email from say, GMail, and be able to read it in some kind of script I could set up on my webspace. If so, could someone point me in the right direction and guide me through a setup? I would really appreciate it because for some reason, I cannot seem to set up other scripts like POPmail 2.1 up correctly.

Thanks in advance.