Adds header to the message
getLogger().debug("sending mail");
Mail mail = session.getMail();
String responseString = null;
try {
mailServer.sendMail(mail);
Collection theRecipients = mail.getRecipients();
String recipientString = "";
if (theRecipients != null) {
recipientString = theRecipients.toString();
}
if (getLogger().isInfoEnabled()) {
StringBuffer infoBuffer =
new StringBuffer(256)
.append("Successfully spooled mail ")
.append(mail.getName())
.append(" from ")
.append(mail.getSender())
.append(" on ")
.append(session.getRemoteIPAddress())
.append(" for ")
.append(recipientString);
getLogger().info(infoBuffer.toString());
}
} catch (MessagingException me) {
// Grab any exception attached to this one.
Exception e = me.getNextException();
// If there was an attached exception, and it's a
// MessageSizeException
if (e != null && e instanceof MessageSizeException) {
// Add an item to the state to suppress
// logging of extra lines of data
// that are sent after the size limit has
// been hit.
session.getState().put(SMTPSession.MESG_FAILED, Boolean.TRUE);
// then let the client know that the size
// limit has been hit.
responseString = "552 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_MSG_TOO_BIG)+" Error processing message.";
StringBuffer errorBuffer =
new StringBuffer(256)
.append("Rejected message from ")
.append(session.getState().get(SMTPSession.SENDER).toString())
.append(" from host ")
.append(session.getRemoteHost())
.append(" (")
.append(session.getRemoteIPAddress())
.append(") exceeding system maximum message size of ")
.append(session.getConfigurationData().getMaxMessageSize());
getLogger().error(errorBuffer.toString());
} else {
responseString = "451 "+DSNStatus.getStatus(DSNStatus.TRANSIENT,DSNStatus.UNDEFINED_STATUS)+" Error processing message.";
getLogger().error("Unknown error occurred while processing DATA.", me);
}
session.writeResponse(responseString);
return;
}
responseString = "250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.CONTENT_OTHER)+" Message received";
session.writeResponse(responseString);