title: Not able to read my gmail inbox using the imap python module
body: <p>Below is the code that is supposed to read my Gmail account. </p>
  
  <pre><code>import smtplib
  import time
  import imaplib
  import email
  from reportlab.pdfgen import canvas
  
  ORG_EMAIL = '@gmail.com'
  FROM_EMAIL = 'amitesh.sahay@gmail.com'
  FROM_PWD = '&lt;my_password&gt;'
  SMTP_SERVER = 'imap.gmail.com'
  SMTP_PORT = 993
  
  # -------------------------------------------------
  #
  # Utility to read email from Gmail Using Python
  #
  # ------------------------------------------------
  
  
  def read_email_from_gmail():
      try:
          mail = imaplib.IMAP4_SSL(SMTP_SERVER)
          mail.login(FROM_EMAIL,FROM_PWD)
          mail.select('inbox')
  
          type1, data = mail.search(None, 'ALL')
          mail_ids = data[0]
  
          id_list = mail_ids.split()
          first_email_id = int(id_list[0])
          latest_email_id = int(id_list[-1])
  
          for i in range(latest_email_id,first_email_id, -1):
              type1, data = mail.fetch(i, '(RFC822)' )
  
              for response_part in data:
                  if isinstance(response_part, tuple):
                      msg = email.message_from_string(response_part[1])
                      email_subject = msg['subject']
                      email_from = msg['from']
                      print('From : ' + email_from + '\n')
                      print('Subject : ' + email_subject + '\n')
  
      except ValueError:
          print("Oops!  That was no valid mailbox.  Try again...")
  </code></pre>
  
  <p>When I execute the code, it runs without throwing any error, but it's not giving any output as well. I am using python 3.6 and Installed all the python package that comes inbuilt within PyCharm. Is there anything that somebody can point out which could be a probable issue?</p>
  
  <p>Please let me know if any further details are required.</p>