/** * Allows ")" or "(" to appear in quoted versions of * the localpart (they are never allowed in unquoted versions). * The default (2822) behavior is to allow this, i.e. boolean true. * You can disallow it, but better to leave it true. */ public RFC2822AddressParser allowParentheseInLocalpart(final boolean allow) { ALLOW_PARENS_IN_LOCALPART = allow; resetPatterns(); return this; }
/** * Defines if quoted identifiers are allowed. * Using quotes and angle brackets around the raw address may be allowed, e.g.: * <p> * <ul> * <li><code>"John Smith" <john.smith@somewhere.com></code></li> * </ul> * <p> * 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 (<code>john.smith@somewhere.com</code> - no quotes or angle * brackets), then set the flag {@code false}. */ public RFC2822AddressParser allowQuotedIdentifiers(final boolean allow) { ALLOW_QUOTED_IDENTIFIERS = allow; resetPatterns(); return this; }
/** * Changes the behavior of the domain parsing. If {@code true}, the parser will * allow 2822 domains, which include single-level domains (e.g. bob@localhost) as well * as domain literals, e.g.: * <p> * <ul> * <li><code>someone@[192.168.1.100]</code> or</li> * <li><code>john.doe@[23:33:A2:22:16:1F]</code> or</li> * <li><code>me@[my computer]</code></li> * </ul> * <p> * The RFC says these are valid email addresses, but many don't like * allowing them. If you don't want to allow them, and only want to allow valid domain names * (<a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>, x.y.z.com, etc), * and specifically only those with at least two levels ("example.com"), then * set this flag to {@code false}. */ public RFC2822AddressParser allowDomainLiterals(final boolean allow) { ALLOW_DOMAIN_LITERALS = allow; resetPatterns(); return this; }
/** * Allows "." to appear in atext (note: only atext which appears * in the 2822 "name-addr" part of the address, not the other instances). * <p> * The addresses: * <ul> * <li><code>Kayaks.org <kayaks@kayaks.org></code></li> * <li><code>Bob K. Smith<bobksmith@bob.net></code></li> * </ul> * ...are not valid. They should be: * <ul> * <li><code>"Kayaks.org" <kayaks@kayaks.org></code></li> * <li><code>"Bob K. Smith" <bobksmith@bob.net></code></li> * </ul> * If this boolean is set to false, the parser will act per 2822 and will require * the quotes; if set to true, it will allow the use of "." without quotes. */ public RFC2822AddressParser allowDotInAtext(final boolean allow) { ALLOW_DOT_IN_ATEXT = allow; resetPatterns(); return this; }
/** * Allows "[" or "]" to appear in atext. * The address: * <ul><li><code>[Kayaks] <kayaks@kayaks.org></code></li></ul> * <p> * ...is not valid. It should be: * <p> * <ul><li><code>"[Kayaks]" <kayaks@kayaks.org></code></li></ul> * <p> * If this boolean is set to false, the parser will act per 2822 and will require * the quotes; if set to true, it will allow them to be missing. * <p> * Use at your own risk. There may be some issue with enabling this feature in conjunction * with {@link #allowDomainLiterals(boolean)}. */ public RFC2822AddressParser allowSquareBracketsInAtext(final boolean allow) { ALLOW_SQUARE_BRACKETS_IN_ATEXT = allow; resetPatterns(); return this; }
/** * Controls the behavior of getInternetAddress. If true, allows the real world practice of: * <ul> * <li><bob@example.com> (Bob Smith)</li> * </ul> * <p> * In this case, "Bob Smith" is not technically the personal name, just a * comment. If this is set to true, the methods will convert this into: * <ul> * <li>Bob Smith <bob@example.com></li> * </ul> * <p> * This also happens somewhat more often and appropriately with * <code>mailer-daemon@blah.com (Mail Delivery System)</code>. * <p> * <p> * If a personal name appears to the left and CFWS appears to the right of an address, * the methods will favor the personal name to the left. If the methods need to use the * CFWS following the address, they will take the first comment token they find. */ public RFC2822AddressParser extractCfwsPersonalName(final boolean extract) { EXTRACT_CFWS_PERSONAL_NAMES = extract; resetPatterns(); return this; }
/** * Allows ")" or "(" to appear in quoted versions of * the localpart (they are never allowed in unquoted versions). * The default (2822) behavior is to allow this, i.e. boolean true. * You can disallow it, but better to leave it true. */ public RFC2822AddressParser allowParentheseInLocalpart(final boolean allow) { ALLOW_PARENS_IN_LOCALPART = allow; resetPatterns(); return this; }
/** * Defines if quoted identifiers are allowed. * Using quotes and angle brackets around the raw address may be allowed, e.g.: * <p> * <ul> * <li><code>"John Smith" <john.smith@somewhere.com></code></li> * </ul> * <p> * 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 (<code>john.smith@somewhere.com</code> - no quotes or angle * brackets), then set the flag {@code false}. */ public RFC2822AddressParser allowQuotedIdentifiers(final boolean allow) { ALLOW_QUOTED_IDENTIFIERS = allow; resetPatterns(); return this; }
/** * Allows "[" or "]" to appear in atext. * The address: * <ul><li><code>[Kayaks] <kayaks@kayaks.org></code></li></ul> * <p> * ...is not valid. It should be: * <p> * <ul><li><code>"[Kayaks]" <kayaks@kayaks.org></code></li></ul> * <p> * If this boolean is set to false, the parser will act per 2822 and will require * the quotes; if set to true, it will allow them to be missing. * <p> * Use at your own risk. There may be some issue with enabling this feature in conjunction * with {@link #allowDomainLiterals(boolean)}. */ public RFC2822AddressParser allowSquareBracketsInAtext(final boolean allow) { ALLOW_SQUARE_BRACKETS_IN_ATEXT = allow; resetPatterns(); return this; }
/** * Changes the behavior of the domain parsing. If {@code true}, the parser will * allow 2822 domains, which include single-level domains (e.g. bob@localhost) as well * as domain literals, e.g.: * <p> * <ul> * <li><code>someone@[192.168.1.100]</code> or</li> * <li><code>john.doe@[23:33:A2:22:16:1F]</code> or</li> * <li><code>me@[my computer]</code></li> * </ul> * <p> * The RFC says these are valid email addresses, but many don't like * allowing them. If you don't want to allow them, and only want to allow valid domain names * (<a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>, x.y.z.com, etc), * and specifically only those with at least two levels ("example.com"), then * set this flag to {@code false}. */ public RFC2822AddressParser allowDomainLiterals(final boolean allow) { ALLOW_DOMAIN_LITERALS = allow; resetPatterns(); return this; }
/** * Allows "." to appear in atext (note: only atext which appears * in the 2822 "name-addr" part of the address, not the other instances). * <p> * The addresses: * <ul> * <li><code>Kayaks.org <kayaks@kayaks.org></code></li> * <li><code>Bob K. Smith<bobksmith@bob.net></code></li> * </ul> * ...are not valid. They should be: * <ul> * <li><code>"Kayaks.org" <kayaks@kayaks.org></code></li> * <li><code>"Bob K. Smith" <bobksmith@bob.net></code></li> * </ul> * If this boolean is set to false, the parser will act per 2822 and will require * the quotes; if set to true, it will allow the use of "." without quotes. */ public RFC2822AddressParser allowDotInAtext(final boolean allow) { ALLOW_DOT_IN_ATEXT = allow; resetPatterns(); return this; }
/** * Controls the behavior of getInternetAddress. If true, allows the real world practice of: * <ul> * <li><bob@example.com> (Bob Smith)</li> * </ul> * <p> * In this case, "Bob Smith" is not technically the personal name, just a * comment. If this is set to true, the methods will convert this into: * <ul> * <li>Bob Smith <bob@example.com></li> * </ul> * <p> * This also happens somewhat more often and appropriately with * <code>mailer-daemon@blah.com (Mail Delivery System)</code>. * <p> * <p> * If a personal name appears to the left and CFWS appears to the right of an address, * the methods will favor the personal name to the left. If the methods need to use the * CFWS following the address, they will take the first comment token they find. */ public RFC2822AddressParser extractCfwsPersonalName(final boolean extract) { EXTRACT_CFWS_PERSONAL_NAMES = extract; resetPatterns(); return this; }