public static void main(String[] args){
  if (args.length != 1) {
    throw new RuntimeException("Usage: [path to conf file]");
  }
  File configuration=new File(args[0]);
  if (configuration.isDirectory() || !configuration.exists()) {
    throw new RuntimeException("Configuration file" + configuration.getAbsolutePath() + " is a directory or "+ "doesn't exist");
  }
  InputStream is=null;
  try {
    is=new FileInputStream(configuration);
    Properties props=new Properties();
    props.load(is);
    String server=props.getProperty("sendemails.server");
    String from=props.getProperty("sendemails.from");
    String subject=props.getProperty("sendemails.subject");
    String mimeType=props.getProperty("sendemails.mimetype");
    String replyTo=props.getProperty("sendemails.replyto");
    String templateName=props.getProperty("sendemails.file.template");
    String recipientsFileName=props.getProperty("sendemails.file.to");
    String template=getTemplate(templateName);
    sendMails(server,from,recipientsFileName,replyTo,subject,mimeType,template);
  }
 catch (  ApiException|IOException|MessagingException|InterruptedException e) {
    LOG.error("Mails sending failed - {}",e.getLocalizedMessage(),e);
    throw new RuntimeException(e.getLocalizedMessage(),e);
  }
 finally {
    if (is != null) {
      try {
        is.close();
      }
 catch (      IOException e) {
        LOG.error("Mails sending failed - {}",e.getLocalizedMessage(),e);
        throw new RuntimeException(e.getLocalizedMessage(),e);
      }
    }
  }
}

public static void main ( String [ ] args ) { if ( args . length != 1 ) { throw new RuntimeException ( "Usage: [path to conf file]" ) ; } File configuration = new File ( args [ 0 ] ) ; if ( configuration . isDirectory ( ) || ! configuration . exists ( ) ) { throw new RuntimeException ( "Configuration file" + configuration . getAbsolutePath ( ) + " is a directory or " + "doesn't exist" ) ; } InputStream is = null ; try { is = new FileInputStream ( configuration ) ; Properties props = new Properties ( ) ; props . load ( is ) ; String server = props . getProperty ( "sendemails.server" ) ; String from = props . getProperty ( "sendemails.from" ) ; String subject = props . getProperty ( "sendemails.subject" ) ; String mimeType = props . getProperty ( "sendemails.mimetype" ) ; String replyTo = props . getProperty ( "sendemails.replyto" ) ; String templateName = props . getProperty ( "sendemails.file.template" ) ; String recipientsFileName = props . getProperty ( "sendemails.file.to" ) ; String template = getTemplate ( templateName ) ; sendMails ( server , from , recipientsFileName , replyTo , subject , mimeType , template ) ; } catch ( ApiException | IOException | MessagingException | InterruptedException e ) { LOG . error ( "Mails sending failed - {}" , e . getLocalizedMessage ( ) , e ) ; throw new RuntimeException ( e . getLocalizedMessage ( ) , e ) ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( IOException e ) { LOG . error ( "Mails sending failed - {}" , e . getLocalizedMessage ( ) , e ) ; throw new RuntimeException ( e . getLocalizedMessage ( ) , e ) ; } } } }
entry point for the application
