Here you can find the source of getSmtpPort(String email)
public static int getSmtpPort(String email) throws Exception
//package com.java2s; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static Map<String, String> hostMap = new HashMap<String, String>(); public static int getSmtpPort(String email) throws Exception { Pattern pattern = Pattern.compile("\\w+@(\\w+)(\\.\\w+){1,2}"); Matcher matcher = pattern.matcher(email); String key = "unSupportEmail"; if (matcher.find()) { key = "smtp.port." + matcher.group(1); }/* www. jav a2 s . c o m*/ if (hostMap.containsKey(key)) { return Integer.parseInt(hostMap.get(key)); } else { return 25; } } }