KNOWN ISSUE:
You receive an authentication error when the script connects to your gmail account. In this case please try the solution below:
Solution:
1. You have to allow pop3 and/or imap in your google account under the tab "forwarding and pop/imap".
2. You have to allow insecure apps:
https://myaccount.google.com/
Here you see also the error messages from google.
3. You have to activate your insecure website
https://accounts.google.com/b/0/DisplayUnlockCaptcha
But pay attention that you are logged in with the correct google account, before you do this. You can't check this on the above site.