/** * Removes everything but the email destination from all recipient fields, * in order to keep local contact names private. * @throws MessagingException */ private void removeRecipientNames() throws MessagingException { removeRecipientNames(RecipientType.TO); removeRecipientNames(RecipientType.CC); removeRecipientNames(RecipientType.BCC); }
private void removeRecipientNames(Message.RecipientType type) throws MessagingException { Address[] recipients = getRecipients(type); if (recipients != null) { removeRecipientNames(recipients); setRecipients(type, recipients); } }
/** * Removes all headers that are not on the whitelist, and initializes some * basic header fields.<br/> * Called by {@link #saveChanges()}, see JavaMail JavaDoc. * @throws MessagingException */ @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); // Depending on includeSendTime, set the send time or remove the send time field if (includeSendTime) { // Ensure the "Date" field is set in UTC time, using the English locale. MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); // always use UTC for outgoing mail if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); }