System.err.println ("IncomingEmailLinkProtocol: Checking inbox access: " + e);
log.error ("Checking inbox access: " + e);
    public void run()     {      //  We don't want this thread to stop until we want it to stop, so      //  we do things very carefully here.  Later on, this and other      //  sensitive threads should probably be monitored.      boolean access;      int n, waitTime;              while (!quitNow)       {        //  Make sure inbox is still accessible        access = false;        n = 0;        while (!quitNow)        {          try          {            access = MailMan.checkMailBoxAccess (inbox);          }          catch (Exception e)          {            System.err.println ("IncomingEmailLinkProtocol: Checking inbox access: " + e);          }          if (access == false)          {            //  Print out a message that the inbox is not accessible            //  and then wait for awhile till we try again.                        n++;                       if (n < 20)       waitTime = 15;            else if (n < 100) waitTime = 30;            else              waitTime = 60;                        if (debug)            {              try              {                String s =  "\nALERT: Unable to access mail inbox:\n" +inbox.toStringDiscreet();                s += "\nTry " +n+ ": Will try to access it again in " +waitTime+ " seconds...";                System.err.println (s);              }               catch (Exception e) {}            }            try { Thread.sleep (waitTime*1000); } catch (Exception e) {}          }          else          {            if (n > 0 && debug) System.err.println ("\nIncomingEmail: Inbox is accessible again.");            break;          }        }        //  Ok, inbox is accessible, now create the email message instream        EmailInputStream emailIn = null;        n = 0;        while (!quitNow)        {          emailIn = createEmailInputStream (mailServerPollTime*1000);          if (emailIn == null)          {            //  This should not happen.  But in case it does, we'll try a few times            //  to see if we can successfully create the instream.  If we fail,             //  we'll head back to checking the mailbox access.            n++;                       if (n < 5) waitTime = 5;            else break;            try { Thread.sleep (waitTime*1000); } catch (Exception e) {}          }          else break;        }        if (emailIn == null) continue;  // go back to check mailbox access        //  Finally, read and process incoming messages.  If we encounter a        //  failure, we close the stream and go back to the top of the loop        //  and start over establishing the inbox access and input stream.        while (!quitNow)        {          if (readAndDeliverMessage (emailIn) == false) break;        }        //  It's important to close the message stream due to its        //  underlying polling email stream.              if (messageIn != null)        {          try { messageIn.close(); } catch (Exception e2) {}          messageIn = null;        }      }        }