CallbackMailServerCheckerImpl extends AbstractEmailChecker { @SuppressWarnings("null") @Override public boolean check(String email) throws TalendSMTPRuntimeException { if (email == null) { return handleEmptyMailCase(); } int pos = email.indexOf('@'); if (pos == -1) { return handleNoATExistCase(); } final Matcher matcher = emailPattern.matcher(email); if (!matcher.find()) { return handleInvalidEmailSyntaxCase(email); } String domain = email.substring(++pos); List<String> mxList = null; try { mxList = getMX(domain); } catch (NamingException ex) { handleNamingExceptionCase(ex); } if (mxList.isEmpty()) { return handleMaxSizeZeroCase(); } String errorMessage = StringUtils.EMPTY; for (int mx = 0; mx < mxList.size(); mx++) { Socket skt = null; try { int res; skt = new Socket(mxList.get(mx), port); BufferedReader rdr = new BufferedReader(new InputStreamReader(skt.getInputStream())); BufferedWriter wtr = new BufferedWriter(new OutputStreamWriter(skt.getOutputStream())); res = getResponse(rdr); if (res != 220) { return handleSMTPServiceReadyCase(mxList, mx, skt); } write(wtr, "EHLO " + domain); res = getResponse(rdr); if (res != 250) { return handleNotESMTPCase(domain, skt); } write(wtr, "MAIL FROM: <" + email + ">"); res = getResponse(rdr); if (res != 250) { return handleSenderRejectedCase(email, skt); } write(wtr, "RCPT TO: <" + email + ">"); res = getResponse(rdr); write(wtr, "RSET"); getResponse(rdr); write(wtr, "QUIT"); getResponse(rdr); if (res != 250) { skt.close(); return false; } rdr.close(); wtr.close(); skt.close(); return true; } catch (IOException e) { if (LOG.isDebugEnabled()) { LOG.debug("Connection to " + mxList.get(mx) + " failed.", e); } errorMessage = e.getMessage(); continue; } finally { if (skt != null) { try { skt.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); } } } } throw new TalendSMTPRuntimeException(errorMessage); } CallbackMailServerCheckerImpl(); void init(); @SuppressWarnings("null") @Override boolean check(String email); @Override EmailVerifyResult checkEmail(String email); @Override EmailVerifyResult check(String email, String... strings);  }
@Test public void testCheck_invalid3() { String email = "talend_testsina.com"; assertFalse(callBackServerCheck.check(email)); }
@Test public void testCheck_invalid4() { String email = null; assertFalse(callBackServerCheck.check(email)); }
@Test public void testCheck_invalid5() { String email = "talend_test@@sina.com"; assertFalse(callBackServerCheck.check(email)); }