title: how to retrieve emails from gmail using imap in php?
body: <p>this is my code</p>
  
  <pre><code>$hostname = '{outlook.office365.com:993/imap/ssl}INBOX';
  $username = 'email@example.com';
  $password = 'password';
  
  $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to `Gmail: ' . imap_last_error());`
  </code></pre>
  
  <p>I have copied this code form another website to test but i am getting this error!!</p>
  
  <blockquote>
    <p>Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in E:\xampp\htdocs\mail\index.php on line 42
    Cannot connect to Gmail: Too many login failures
    Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0</p>
    
    <p>Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0</p>
    
    <p>Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0</p>
    
    <p>Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0</p>
  </blockquote>