* @param msgIn the stream containing the message content
*/
private void processMail(MailHeaders headers, InputStream msgIn)
throws MessagingException {
ByteArrayInputStream headersIn = null;
MailImpl mail = null;
List recipientCollection = null;
try {
headersIn = new ByteArrayInputStream(headers.toByteArray());
recipientCollection = (List) state.get(RCPT_LIST);
mail =
new MailImpl(theConfigData.getMailServer().getId(),
(MailAddress) state.get(SENDER),
recipientCollection,
new SequenceInputStream(headersIn, msgIn));
// Call mail.getSize() to force the message to be
// loaded. Need to do this to enforce the size limit
if (theConfigData.getMaxMessageSize() > 0) {
mail.getMessageSize();
}
mail.setRemoteHost(remoteHost);
mail.setRemoteAddr(remoteIP);
theConfigData.getMailServer().sendMail(mail);
Collection theRecipients = mail.getRecipients();
String recipientString = "";
if (theRecipients != null) {
recipientString = theRecipients.toString();
}
if (getLogger().isDebugEnabled()) {
StringBuffer debugBuffer =
new StringBuffer(256)
.append("Successfully spooled mail )")
.append(mail.getName())
.append(" from ")
.append(mail.getSender())
.append(" for ")
.append(recipientString);
getLogger().debug(debugBuffer.toString());
} else if (getLogger().isInfoEnabled()) {
StringBuffer infoBuffer =
new StringBuffer(256)
.append("Successfully spooled mail from ")
.append(mail.getSender())
.append(" for ")
.append(recipientString);
getLogger().info(infoBuffer.toString());
}
} finally {
if (recipientCollection != null) {
recipientCollection.clear();
}
recipientCollection = null;
if (mail != null) {
mail.dispose();
}
mail = null;
if (headersIn != null) {
try {
headersIn.close();