I have enabled OpenSSL and IMAP functions from my php.ini file and phpinfo() confirms it.
OpenSSL
IMAP
php.ini
phpinfo()
By using the code below
If you get blocked, this can be because google sees a login from a new device.
Go to your google account and check https://myaccount.google.com/device-activity and let them know the 'Unknown device is ok to use'.