mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
邮箱校验添加对中文的支持
This commit is contained in:
parent
9c532f8a15
commit
7894e58171
@ -59,11 +59,11 @@ public interface RegexPool {
|
||||
*/
|
||||
String MONEY = "^(\\d+(?:\\.\\d+)?)$";
|
||||
/**
|
||||
* 邮件,符合RFC 5322规范,正则来自:<a href="http://emailregex.com/">http://emailregex.com/</a>
|
||||
* 邮件,符合RFC 5322规范。
|
||||
* What is the maximum length of a valid email address? <a href="https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/44317754">https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/44317754</a>
|
||||
* 注意email 要宽松一点。比如 jetz.chong@hutool.cn、jetz-chong@ hutool.cn、jetz_chong@hutool.cn、dazhi.duan@hutool.cn 宽松一点把,都算是正常的邮箱
|
||||
*/
|
||||
String EMAIL = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])";
|
||||
String EMAIL = "(?:[a-z0-9\\u4e00-\\u9fa5!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9\\u4e00-\\u9fa5!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9\\u4e00-\\u9fa5](?:[a-z0-9\\u4e00-\\u9fa5-]*[a-z0-9\\u4e00-\\u9fa5])?\\.)+[a-z0-9\\u4e00-\\u9fa5](?:[a-z0-9\\u4e00-\\u9fa5-]*[a-z0-9\\u4e00-\\u9fa5])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9\\u4e00-\\u9fa5-]*[a-z0-9\\u4e00-\\u9fa5]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])";
|
||||
/**
|
||||
* 移动电话<br>
|
||||
* eg: 中国大陆: +86 180 4953 1399,2位区域码标示+13位数字
|
||||
|
@ -121,6 +121,8 @@ public class ValidatorTest {
|
||||
Assertions.assertTrue(email3);
|
||||
final boolean email4 = Validator.isEmail("xiaolei.Lu@aaa.b");
|
||||
Assertions.assertTrue(email4);
|
||||
final boolean email5 = Validator.isEmail("luxiaolei_小磊@小磊.com");
|
||||
Assertions.assertTrue(email5);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -31,10 +31,10 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* 邮件工具类,基于javax.mail封装
|
||||
* 邮件工具类,基于jakarta.mail封装
|
||||
*
|
||||
* @author looly
|
||||
* @since 3.1.2
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class MailUtil {
|
||||
/**
|
||||
@ -387,7 +387,7 @@ public class MailUtil {
|
||||
}
|
||||
|
||||
return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
|
||||
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
||||
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------------ Private method start
|
||||
|
Loading…
x
Reference in New Issue
Block a user