Java Email Validate getSmtpPort(String email)

Here you can find the source of getSmtpPort(String email)

Description

get Smtp Port

License

Open Source License

Declaration

public static int getSmtpPort(String email) throws Exception 

Method Source Code

//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;
        }
    }
}

Related

  1. getEmailAddressFromDN(String dn)
  2. getEmailListStr(String tempStr)
  3. getEmails(String str)
  4. getFirstEmailAddr(String s)
  5. getSafeMailAddr(String mailAddr)
  6. isEmail(CharSequence email)
  7. isEmail(CharSequence input)
  8. isEmail(final String email)
  9. isEmail(final String s)