org.codemonkey.simplejavamail.EmailAddressValidationCriteria Maven / Gradle / Ivy
Show all versions of simple-java-mail Show documentation
package org.codemonkey.simplejavamail;
/**
* Defines a set of restriction flags for email address validation. To remain completely true to RFC 2822, all flags should be set to
* true
.
*
* @author Benny Bottema
* @see #EmailAddressValidationCriteria(boolean, boolean)
*/
public class EmailAddressValidationCriteria {
private final boolean allowDomainLiterals;
private final boolean allowQuotedIdentifiers;
/**
* @param allowDomainLiterals
* - This flag states whether domain literals are allowed in the email address, e.g.:
*
* someone@[192.168.1.100] or
* john.doe@[23:33:A2:22:16:1F] or
* me@[my computer]
*
*
* The RFC says these are valid email addresses, but most people don't like allowing them. If you don't want to allow them,
* and only want to allow valid domain names (RFC 1035, x.y.z.com, etc),
* change this constant to false.
*
* Its default value is true to remain RFC 2822 compliant, but you should set it depending on what you need for your
* application.
*
*
* @param allowQuotedIdentifiers
* - This flag states whether quoted identifiers are allowed (using quotes and angle brackets around the raw address) are
* allowed, e.g.:
*
* "John Smith" <[email protected]>
*
* The RFC says this is a valid mailbox. If you don't want to allow this, because for example, you only want users to enter
* in a raw address ([email protected] - no quotes or angle brackets), then change this constant to
* false.
*
* Its default value is true to remain RFC 2822 compliant, but you should set it depending on what you need for your
* application.
*
*
*/
public EmailAddressValidationCriteria(boolean allowDomainLiterals, boolean allowQuotedIdentifiers) {
this.allowDomainLiterals = allowDomainLiterals;
this.allowQuotedIdentifiers = allowQuotedIdentifiers;
}
public final boolean isAllowDomainLiterals() {
return allowDomainLiterals;
}
public final boolean isAllowQuotedIdentifiers() {
return allowQuotedIdentifiers;
}
}