+ private static void sortMX(String[] mxhosts) {
+ Arrays.sort(mxhosts, new Comparator<String>() {
+
+ @Override
+ public int compare(String o1, String o2) {
+ int i1 = Integer.parseInt(o1.split(" ")[0]);
+ int i2 = Integer.parseInt(o2.split(" ")[0]);
+ return Integer.compare(i1, i2);
+ }
+ });
+ }
+
+ public static boolean isValidMailAddress(String address) {
+ if ( !MAIL_ADDRESS.matcher(address).matches()) {
+ return false;
+ }
+
+ String[] parts = address.split("@", 2);
+
+ String local = parts[0];
+ String domain = parts[1];
+
+ if ( !MAIL_LOCAL.matcher(local).matches()) {
+ return false;
+ }
+
+ for (String domainPart : domain.split("\\.", -1)) {
+ if ( !DomainAssessment.isValidDomainPart(domainPart)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+