/** * Does some email address checking. * @param email * @return true if it looks OK, false otherwise */ public boolean isValidEmail(String email) { String domain = null; try { // Does it have an @ in it? if ( email.indexOf("@") == -1 ) { return false; } domain = email.split("@")[1]; String mxHost = getBestMxHost(domain); if ( mxHost == null ) { // Should we return false here? It's possible to have emails set // up to be delivered by A records too. logger.debug("Can't find MX record for " + domain); return false; } return true; } catch ( NameNotFoundException nnfe ) { logger.error("Domain " + domain + " not found - " + nnfe.getMessage()); return false; } catch ( Exception e ) { logger.error("", e); return false; } }