public static void checkConnection(@Nonnull String hostname,@Nonnull String username,@Nonnull String password,@Nonnull String encryption,int port,boolean disableCertificateChecking) throws MessagingException {
  Properties props=createProperties(hostname,port,encryption,disableCertificateChecking);
  Session session=Session.getInstance(props,null);
  Transport transport=session.getTransport("smtp");
  transport.connect(username,password);
  transport.close();
}

public static void checkConnection ( @ Nonnull String hostname , @ Nonnull String username , @ Nonnull String password , @ Nonnull String encryption , int port , boolean disableCertificateChecking ) throws MessagingException { Properties props = createProperties ( hostname , port , encryption , disableCertificateChecking ) ; Session session = Session . getInstance ( props , null ) ; Transport transport = session . getTransport ( "smtp" ) ; transport . connect ( username , password ) ; transport . close ( ) ; }
check smtp login credentials
