| | |
| | | import javax.mail.MessagingException; |
| | | import javax.mail.internet.MimeMessage; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | public class EmailService { |
| | | |
| | | private static final String EMAIL_REGEX = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$"; |
| | | |
| | | @Value("${spring.mail.username}") |
| | | private String from; |
| | | |
| | | private final static String TEMPLATE = "Your verification code is: ${code}"; |
| | | |
| | | @Autowired |
| | | @SuppressWarnings("all") |
| | |
| | | } |
| | | } |
| | | |
| | | public boolean isValid(String email) { |
| | | if (Cools.isEmpty(email)) { |
| | | return false; |
| | | } |
| | | Pattern pattern = Pattern.compile(EMAIL_REGEX); |
| | | Matcher matcher = pattern.matcher(email); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | } |