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

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    11

    Question imaplib question...


    Hi.
    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
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0
    Well, I have not messed around with imaplib but when you try to connect to a server:
    m = imaplib.IMAP4(host="127.0.0.1",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="127.0.0.1",port=143)
    ... except:
    ... print("You were not logged in")
    ...
    You were not logged in
    >>>

IMN logo majestic logo threadwatch logo seochat tools logo