EmailUtil.java 759 B

1234567891011121314151617181920212223242526272829
  1. package com.rf.AIquantum.utils;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.apache.commons.net.smtp.SMTPClient;
  4. import org.apache.commons.net.smtp.SMTPReply;
  5. import org.xbill.DNS.Lookup;
  6. import org.xbill.DNS.Record;
  7. import org.xbill.DNS.Type;
  8. import java.io.IOException;
  9. import java.util.regex.Matcher;
  10. import java.util.regex.Pattern;
  11. @Slf4j
  12. public class EmailUtil {
  13. private static final String EMAIL_REGEX = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
  14. public static boolean checkEmail(String email) {
  15. if (email == null || email.isEmpty()) {
  16. return false;
  17. }
  18. Pattern pattern = Pattern.compile(EMAIL_REGEX);
  19. Matcher matcher = pattern.matcher(email);
  20. return matcher.matches();
  21. }
  22. }