code: void validateAndPrepare(Message message, Address[] addresses) throws MessagingException {
          if (message.getFrom() == null || message.getFrom().length == 0) {
              fail(message, addresses, "No or empty FROM address set!");
          }
          if (addresses.length == 0) {
              fail(message, addresses, "No RECIPIENTS set!");
          }
          Address[] messageAddresses = message.getAllRecipients();
          if (messageAddresses == null) {
              for(Address address : addresses) {
                  message.addRecipient(Message.RecipientType.TO, address);
              }
          } else {
              out:
              for(Address address : addresses) {
                  for(Address a : messageAddresses) {
                      if (a == null) {
                          continue;
                      }
                      if (a.equals(address)) {
                          continue out;
                      }
                  }
                  message.addRecipient(Message.RecipientType.TO, address);
              }
          }
      }
docs: Validate FROM and RECIPIENTS
  @param message message to validate
  @param addresses addresses to be added into message if not duplicated
  @throws MessagingException