// Check if the X-been-there header is set to the listserv's name
// (the address). If it has, this means it's a message from this
// listserv that's getting bounced back, so we need to swallow it
if (address.toString().equals(
outgoingMessage.getHeader("X-been-there"))) {
throw new RejectExceptionExt(new EnhancedStatus(450, "4.4.6",
"Mail list loop detected"));
}
setSubject(outgoingMessage);
// If replies should go to this list, we need to set the header
if (replyToList) {
outgoingMessage.setHeader("Reply-To", address.toString());
}
// We're going to set this special header to avoid bounces
// getting sent back out to the list
outgoingMessage.setHeader("X-been-there", address.toString());
outgoingMessage.setHeader("List-Id", "<" + listId + ">");
outgoingMessage.setHeader("List-Post", "<" + address + ">");
outgoingMessage.removeHeader("List-Help");
outgoingMessage.removeHeader("List-Unsubscribe");
outgoingMessage.removeHeader("List-Subscribe");
outgoingMessage.removeHeader("List-Owner");
outgoingMessage.removeHeader("List-Archive");
return outgoingMessage;
} catch (MessagingException e) {
logger.error("Cannot create a mail list MimeMessage", e);
throw new RejectExceptionExt(
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
}
}