I am trying to access gmail inbox to read the emails via php code.
$hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
but getting below error.
imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX`
in some of solution there is option given to enable less secure apps. but gmail has no longer this setting enabled.
Try to lookout setting for less secure apps but this setting is no longer available.