java.lang.Object
com.sanctionco.jmail.JMail
Provides static methods to validate an email address
using standard RFC validation, or to create a new
EmailValidator
.-
Method Summary
Modifier and TypeMethodDescriptionstatic void
enforceValid
(String email) Require that the given email address passes basic RFC validation, throwingInvalidEmailException
if the address is invalid.static boolean
Return true if the given email address fails basic RFC validation.static boolean
Return true if the given email address passes basic RFC validation.static EmailValidator
Returns a new instance ofEmailValidator
with stricter rules applied to the validator.Parse the given email address into a newEmail
object.static EmailValidator
Returns a new instance ofEmailValidator
.
-
Method Details
-
validator
Returns a new instance ofEmailValidator
. In general, you should favor usingstrictValidator()
instead of this method, as this method will allow IP address domain literals, dotless domains, and explicit source routing unless configured separately.- Returns:
- the new
EmailValidator
instance
-
strictValidator
Returns a new instance ofEmailValidator
with stricter rules applied to the validator. The following rules are applied and do not need to be added:- The email address cannot have an IP Address domain
- The email address cannot have a dotless domain
- The email address cannot have explicit source routing
- Returns:
- the new
EmailValidator
instance
-
isValid
Return true if the given email address passes basic RFC validation. SeetryParse(String)
for details on what is required of an email address within basic validation.- Parameters:
email
- the email address to validate- Returns:
- true if the given string is a valid email address, false otherwise
-
isInvalid
Return true if the given email address fails basic RFC validation. SeetryParse(String)
for details on what is required of an email address within basic validation.- Parameters:
email
- the email address to validate- Returns:
- true if the given string is not a valid email address, false otherwise
-
enforceValid
Require that the given email address passes basic RFC validation, throwingInvalidEmailException
if the address is invalid. SeetryParse(String)
for details on what is required of an email address within basic validation.- Parameters:
email
- the email address to validate- Throws:
InvalidEmailException
- if the validation fails
-
tryParse
Parse the given email address into a newEmail
object. This method does basic validation on the input email address. This method does not claim to be 100% accurate in determining if an email address is valid or invalid due to the complexity of the email RFC standards. That being said, if you come across an email address that you expect to be valid that fails validation, or vice-versa, please open an issue at the GitHub repo so it can be fixed.In general, this method should be more or less compliant with the latest RFCs.
-