title: Java mail API connect store in local server but not connected in development server
body: <p>I am new in Java Mail API, I had tried to implement a web application using Tomcat Server which reads I reads gmail inbox and working fine. But when I upload my code to development server it throws below exception </p>
  
  <pre><code>javax.mail.AuthenticationFailedException: [ALERT] Please log in via your web browser: http://support.google.com/mail/accounts/bin/answer.py?answer=78754 (Failure)
      at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:660)
      at javax.mail.Service.connect(Service.java:317)
      at sales_order.ReadInquiryViaEmail.run(ReadInquiryViaEmail.java:89)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>And my code is</p>
  
  <pre><code>public class ReadInquiryViaEmail implements Runnable {
  
      public ReadInquiryViaEmail(ServletContext context, String emailAddress,
                                 String domainName, String protocol, String password) {
  
          this.sContext = context;
          this.domainName = domainName;
          this.emailAddress = emailAddress;
          this.password = password;
          this.protocol = protocol;
      }
  
      public void run() {
          Properties imapProps;=new Properties();
          imapProps.setProperty("mail.host", domainName);
          imapProps.setProperty("mail.port", "993");
          imapProps.setProperty("mail.transport.protocol", protocol);
          imapProps.setProperty("mail.imaps.starttls.enable", "true");
          imapProps.setProperty("username", emailAddress);
          imapProps.setProperty("password", password);
  
          int port = Integer.parseInt("993");
  
          Authenticator authenticator = new Authenticator() {
              protected PasswordAuthentication getPasswordAuthentication() {
                  return new PasswordAuthentication(emailAddress, password);
              }
          };
  
          Session mailSession = Session.getInstance(imapProps, authenticator);
  
          try {
  
              Store store = mailSession.getStore(protocol);
              store.connect(domainName, port, emailAddress, password);
  
              Folder folder = store.getFolder("Inbox");
              folder.open(Folder.READ_WRITE);
  
              folder.getMessages();
              FlagTerm term = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
              Message[] messages = folder.search(term);
              System.out.println("messages.length &gt; " + messages.length);
              if (messages.length &gt; 0) {
                  InternetAddress[] autoResponseEmailAddress =
                          new InternetAddress[messages.length];
  
                  String autoResponseNames[] = new String[messages.length];
                  Inquiry[] emailInquiries = new Inquiry[messages.length];
                  String name = "", subject, emailAddress;
  
                  int index = 0;
                  System.out.println(" reading mails start ");
                  for (int j = (messages.length - 1); j &gt; (-1); j--, index++) {
                      messages[j].setFlag(Flags.Flag.SEEN, true);
  
                      Address address = messages[j].getFrom()[0];
  
                      autoResponseEmailAddress[j] = (InternetAddress) address;
                      autoResponseNames[j] = autoResponseEmailAddress[j].getPersonal();
                      emailAddress = autoResponseEmailAddress[j].getAddress();
  
                      name = autoResponseNames[j];
                      subject = messages[j].getSubject();
  
                      System.out.println(" name " + name);
                      System.out.println(" subject " + subject);
  
                  }
              }
              folder.close(false);
              store.close();
              System.out.println("\n\ndone reading mails\n\n");
          } catch (javax.mail.NoSuchProviderException nspe) {
              logError(nspe);
          } catch (MessagingException e) {
              logError(e);
          } catch (Exception exp) {
              logError(exp);
          }
      }
  }
  </code></pre>
  
  <p>Anything missing in above code ?</p>
  
  <p>Please help.</p>
  
  <p>Thanks in advance.</p>