1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Rep Power

    Question imaplib question...

    I've been messing around with imaplib some and I was wondering how to check if you are logged into a server. Does anyone know how to do this?
    Thanks in advance.
    Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Tucson AZ
    Rep Power
    Well, I have not messed around with imaplib but when you try to connect to a server:
    m = imaplib.IMAP4(host="",port=143)
    Will give you a connection refused if you can't connect.

    Just put the attempt to connect in a try block as in the example below...

    >>> try:
    ... m = imaplib.IMAP4(host="",port=143)
    ... except:
    ... print("You were not logged in")
    You were not logged in

IMN logo majestic logo threadwatch logo seochat tools logo