/** * Splits recipients into domain recipients and external recipients. The agent's domains are used to determine a recipients category. * @param domain A collection of local domains supported by the agent. */ protected void categorizeRecipients(Collection<String> domains) { if (domains == null || domains.size() == 0) { throw new IllegalArgumentException(); } NHINDAddressCollection recipients = this.getRecipients(); this.domainRecipients = new NHINDAddressCollection(); this.otherRecipients = new ArrayList<NHINDAddress>(); for (NHINDAddress address : recipients) { if (address.isInDomain(domains)) { this.domainRecipients.add(address); } else { this.otherRecipients.add(address); } } }
/** * Get the recipients of a message by retrieving the recipient list from the SMTP envelope first, then falling back to the recipients * in the message if the recipients cannot be retrieved from the SMTP envelope. * @param mail The mail object that contains information from the SMTP envelope. * @return Collection of message recipients. * @throws MessagingException */ public static NHINDAddressCollection getMailRecipients(SMTPMailMessage mail) throws MessagingException { final NHINDAddressCollection recipients = new NHINDAddressCollection(); // uses the RCPT TO commands final Collection<InternetAddress> recips = mail.getRecipientAddresses(); if (recips == null || recips.size() == 0) { // fall back to the mime message list of recipients final Address[] recipsAddr = mail.getMimeMessage().getAllRecipients(); for (Address addr : recipsAddr) { recipients.add(new NHINDAddress(addr.toString(), (AddressSource)null)); } } else for (InternetAddress addr : recips) recipients.add(new NHINDAddress(addr)); return recipients; }
retVal.add(new NHINDAddress(addr.getAddress(), source));
xdRecipients.add(new NHINDAddress(s));