code: public static Predicate<MailMessage> forSubjectAndHeaders(final Pattern subjectPattern, final String headerName,
  			final String headerValue) {
  		return new Predicate<MailMessage>() {
  			@Override
  			public boolean apply(final MailMessage input) {
  				boolean result = false;
  				List<String> headers = input.getHeaders().get(headerName);
  				for (String singleHeader : headers) {
  					if (StringUtils.equals(singleHeader, headerValue)) {
  						result = true;
  						break;
  					}
  				}
  				return result && subjectPattern.matcher(input.getSubject()).matches();
  			}
  
  			@Override
  			public String toString() {
  				return String.format("subject to match pattern '%s' and headers to include header '%s=%s'",
  						subjectPattern, headerName, headerValue);
  			}
  		};
  	}
docs: Creates a {@link Predicate} for matching a mail header and subject. If multiple header values
  are present for the given header name this Predicate returns true if at least one header
  value matches the given header value.
  
  @param subjectPattern
  the regex pattern to match
  @param headerName
  the header name to match
  @param headerValue
  the header value to match
  @return the predicate