size = Integer.parseInt(mailOptionValue);
} catch (NumberFormatException pe) {
session.getLogger().error("Rejected syntactically incorrect value for SIZE parameter.");
// This is a malformed option value. We return an error
return new HookResult(HookReturnCode.DENY,
SMTPRetCode.SYNTAX_ERROR_ARGUMENTS,
DSNStatus.getStatus(DSNStatus.PERMANENT,
DSNStatus.DELIVERY_INVALID_ARG)
+ " Syntactically incorrect value for SIZE parameter");
}
if (session.getLogger().isDebugEnabled()) {
StringBuilder debugBuffer = new StringBuilder(128).append(
"MAIL command option SIZE received with value ").append(
size).append(".");
session.getLogger().debug(debugBuffer.toString());
}
long maxMessageSize = session.getMaxMessageSize();
if ((maxMessageSize > 0) && (size > maxMessageSize)) {
// Let the client know that the size limit has been hit.
StringBuilder errorBuffer = new StringBuilder(256).append(
"Rejected message from ").append(
tempSender != null ? tempSender : null).append(
" from host ").append(session.getRemoteHost()).append(" (")
.append(session.getRemoteIPAddress()).append(") of size ")
.append(size).append(
" exceeding system maximum message size of ")
.append(maxMessageSize).append("based on SIZE option.");
session.getLogger().error(errorBuffer.toString());
return new HookResult(HookReturnCode.DENY, SMTPRetCode.QUOTA_EXCEEDED, DSNStatus
.getStatus(DSNStatus.PERMANENT,
DSNStatus.SYSTEM_MSG_TOO_BIG)
+ " Message size exceeds fixed maximum message size");
} else {
// put the message size in the message state so it can be used