title: NameError: name 'mail' is not defined
body: <p>i am very new to programming, i am supposed to count the number of unread eamails in my inbos usiong python. i am getting a name error saying that "mail" is not defined. i am not sure about the logic either. Here is the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import imaplib
  
  &lt;!-- begin snippet: js hide: false console: true babel: false --&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>import datetime
  import email
  import getpass
  
  
  def readmail():
      mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
      mypassword = getpass.getpass("Password: ")
  address = '@mail.com'
  mail.login(address, mypassword)
  now = datetime.date.today()
  mail.select("inbox")
  print("Checking for new e-mails for ", address, ".")
  typ, messageIDs = mail.search(now, "UNSEEN")
  messageIDsString = str(messageIDs[0], encoding='utf8')
  listOfSplitStrings = messageIDsString.split(" ")
  print (len(listOfSplitStrings))
  </code></pre>