private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
/** * Return the members of a group address. A group may have zero, * one, or more members. If this address is not a group, null * is returned. The <code>strict</code> parameter controls whether * the group list is parsed using strict RFC 822 rules or not. * The parsing is done using the <code>parseHeader</code> method. * * @param strict use strict RFC 822 rules? * @return array of InternetAddress objects, or null * @exception AddressException if the group list can't be parsed * @since JavaMail 1.3 */ public InternetAddress[] getGroup(boolean strict) throws AddressException { String addr = getAddress(); if (addr == null) return null; // groups are of the form "name:addr,addr,...;" if (!addr.endsWith(";")) return null; int ix = addr.indexOf(':'); if (ix < 0) return null; // extract the list String list = addr.substring(ix + 1, addr.length() - 1); // parse it and return the individual addresses return InternetAddress.parseHeader(list, strict); }
/** * Return the members of a group address. A group may have zero, * one, or more members. If this address is not a group, null * is returned. The <code>strict</code> parameter controls whether * the group list is parsed using strict RFC 822 rules or not. * The parsing is done using the <code>parseHeader</code> method. * * @param strict use strict RFC 822 rules? * @return array of InternetAddress objects, or null * @exception AddressException if the group list can't be parsed * @since JavaMail 1.3 */ public InternetAddress[] getGroup(boolean strict) throws AddressException { String addr = getAddress(); if (addr == null) return null; // groups are of the form "name:addr,addr,...;" if (!addr.endsWith(";")) return null; int ix = addr.indexOf(':'); if (ix < 0) return null; // extract the list String list = addr.substring(ix + 1, addr.length() - 1); // parse it and return the individual addresses return InternetAddress.parseHeader(list, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
private Address[] getHeaderAsInternetAddresses(String header, boolean strict) throws MessagingException { // NB: We're using getHeader() here to allow subclasses an opportunity to perform lazy loading // of the headers. String mergedHeader = getHeader(header, ","); if (mergedHeader != null) { return InternetAddress.parseHeader(mergedHeader, strict); } return null; }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
/** * Returns the values of all "Reply-To" headers (usually zero or one). * Unlike {@link #getReplyTo()}, this method does not return * the "From" address if there is no "Reply To" address.<br/> * Not to be confused with {@link #getReplyAddress(Identities)}. * @throws MessagingException */ public Address[] getReplyToAddresses() throws MessagingException { String s = getHeader("Reply-To", ","); return (s == null) ? null : InternetAddress.parseHeader(s, true); }
private Address[] getHeaderAsInternetAddresses(String header, boolean strict) throws MessagingException { // NB: We're using getHeader() here to allow subclasses an opportunity to perform lazy loading // of the headers. String mergedHeader = getHeader(header, ","); if (mergedHeader != null) { return InternetAddress.parseHeader(mergedHeader, strict); } return null; }
protected List<InternetAddress> getAllRecipients(MimeMessage mimeMessage) throws MessagingException { List<InternetAddress> recipientList = new ArrayList<InternetAddress>(); for (String recipientHeader : RECIPIENT_HEADERS) { final String recipientHeaderValue = mimeMessage.getHeader(recipientHeader, ","); if (recipientHeaderValue != null) { // parse headers in non strict mode recipientList.addAll(Arrays.asList(InternetAddress.parseHeader(recipientHeaderValue, false))); } } return recipientList; }
private Address[] getAddressHeader(String name) throws MessagingException { String s = getHeader(name, ","); return (s == null) ? null : InternetAddress.parseHeader(s, strict); }
static Stream<String> toAddressContents(String[] headers) { return StreamUtils.ofNullable(headers) .map(Throwing.function(string -> InternetAddress.parseHeader(string, !STRICT_PARSING))) .flatMap(AddressHelper::asStringStream); }
/** * Return the members of a group address. A group may have zero, * one, or more members. If this address is not a group, null * is returned. The <code>strict</code> parameter controls whether * the group list is parsed using strict RFC 822 rules or not. * The parsing is done using the <code>parseHeader</code> method. * * @param strict use strict RFC 822 rules? * @return array of InternetAddress objects, or null * @exception AddressException if the group list can't be parsed * @since JavaMail 1.3 */ public InternetAddress[] getGroup(boolean strict) throws AddressException { String addr = getAddress(); if (addr == null) return null; // groups are of the form "name:addr,addr,...;" if (!addr.endsWith(";")) return null; int ix = addr.indexOf(':'); if (ix < 0) return null; // extract the list String list = addr.substring(ix + 1, addr.length() - 1); // parse it and return the individual addresses return InternetAddress.parseHeader(list, strict); }
/** * Return the members of a group address. A group may have zero, * one, or more members. If this address is not a group, null * is returned. The <code>strict</code> parameter controls whether * the group list is parsed using strict RFC 822 rules or not. * The parsing is done using the <code>parseHeader</code> method. * * @return array of InternetAddress objects, or null * @exception AddressException if the group list can't be parsed * @since JavaMail 1.3 */ public InternetAddress[] getGroup(boolean strict) throws AddressException { String addr = getAddress(); // groups are of the form "name:addr,addr,...;" if (!addr.endsWith(";")) return null; int ix = addr.indexOf(':'); if (ix < 0) return null; // extract the list String list = addr.substring(ix + 1, addr.length() - 1); // parse it and return the individual addresses return InternetAddress.parseHeader(list, strict); }
private boolean hasValidFrom(JavaxMailMessage message) { String[] fromHeaders = message.getHeader("From"); Preconditions.checkState(fromHeaders.length == 1, "Expected exactly 1 From header, got: " + Arrays.toString(fromHeaders)); String rawAddress = fromHeaders[0].replaceAll("\\s+"," "); try { InternetAddress[] address = InternetAddress.parseHeader(rawAddress, true); Preconditions.checkState(address.length == 1, "Expected exactly 1 From address, got: " + Arrays.toString(address)); System.err.format("Valid? %s == %s\n", address[0].toString(), rawAddress); return address[0].toString().equals(rawAddress); } catch (AddressException e) { System.err.format("Not valid from because: %s", e.getMessage()); return false; } }