how can i be able to check weather particular username or password is correct or the session is created after getting autharised :  how can i be able to check weather particular username or password is correct or the session is created after getting autharised


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       
            final String uid=jTextField1.getText();
            String pass = new String(jPasswordField1.getPassword());
            
            //server Config
            Properties prop=new Properties();
            prop.put("mail.smtp.auth","true");
            prop.put("mail.smtp.starttls.enable","true");
            prop.put("mail.smtp.host","smtp.gmail.com");   
            prop.put("mail.smtp.port","587");

            //client Authentication
            Authenticator auth=new Authenticator()
            {
              protected PasswordAuthentication getPasswordAuthentication()
            {
              return new PasswordAuthentication(uid,pass);
            }
            };

            //Session Creation
            Session session= Session.getInstance(prop,auth);
        
        try{
            String to=JOptionPane.showInputDialog("To :");
            String sub=JOptionPane.showInputDialog("Subject :");
            String data=JOptionPane.showInputDialog("Compose :"); 

            //Message Creation
            Message msg=new MimeMessage(session);
            msg.setFrom(new InternetAddress(uid));
      msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
            msg.setSubject(sub);
            msg.setText(data);
            //sending msg
            Transport.send(msg);
            JOptionPane.showMessageDialog(null,"sent !");

            // TODO add your handling code here:
             } catch (MessagingException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }                 