SHARE
TWEET

Untitled

a guest Oct 4th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. import imaplib
  3. import sys
  4.  
  5. host = "your_imap_server"
  6. user = "your_name"
  7. password = "your_password"
  8.  
  9. def test_plain():
  10.     try:
  11.         server = imaplib.IMAP4(host, 143)
  12.         #server.debug = 4
  13.         server.login(user, password)
  14.         server.select()
  15.         typ, msgnums = server.search(None, 'ALL')
  16.         print("message numbers = " + str(msgnums))
  17.         server.close()
  18.         server.logout()
  19.     except:
  20.         print("plain 143 failed:", sys.exc_info()[0])
  21.    
  22. def test_143_starttls():
  23.     try:
  24.         server = imaplib.IMAP4(host, 143)
  25.         #server.debug = 4
  26.         server.starttls()
  27.         server.login(user, password)
  28.         server.select()
  29.         typ, msgnums = server.search(None, 'ALL')
  30.         print("message numbers = " + str(msgnums))
  31.         server.close()
  32.         server.logout()
  33.     except:
  34.         print("STARTTLS 143 failed:", sys.exc_info()[0])
  35.    
  36. def test_993():
  37.     try:
  38.         server = imaplib.IMAP4_SSL(host, 993)
  39.         #server.debug = 4
  40.         server.login(user, password)
  41.         server.select()
  42.         typ, msgnums = server.search(None, 'ALL')
  43.         print("message numbers = " + str(msgnums))
  44.         server.close()
  45.         server.logout()
  46.     except:
  47.         print("SSL 993:", sys.exc_info()[0])
  48.  
  49. test_plain()
  50. test_143_starttls()
  51. test_993()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top