@Override @SuppressWarnings("unchecked") public List<String> getImplementedEsmtpFeatures(SMTPSession session) { // Extension defined in RFC 1870 long maxMessageSize = session.getConfiguration().getMaxMessageSize(); if (maxMessageSize > 0) { return Arrays.asList("SIZE " + maxMessageSize); } else { return Collections.EMPTY_LIST; } }
@Override protected Response doCoreCmd(SMTPSession session, String command, String parameters) { session.setAttachment(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME, ProtocolSession.State.Connection); StringBuilder response = new StringBuilder(); response.append(session.getConfiguration().getHelloName()).append( " Hello ").append(parameters).append(" [").append( session.getRemoteAddress().getAddress().getHostAddress()).append("])"); return new SMTPResponse(SMTPRetCode.MAIL_OK, response); }
@Override public Response onConnect(SMTPSession session) { String smtpGreeting = session.getConfiguration().getGreeting(); SMTPResponse welcomeResponse; // if no greeting was configured use a default if (smtpGreeting == null) { // Initially greet the connector welcomeResponse = new SMTPResponse(SMTPRetCode.SERVICE_READY, new StringBuilder(256) .append(session.getConfiguration().getHelloName()) .append(" ").append(getServiceType(session)).append(" Server (") .append(session.getConfiguration().getSoftwareName()) .append(") ready")); } else { welcomeResponse = new SMTPResponse(SMTPRetCode.SERVICE_READY,smtpGreeting); } return welcomeResponse; }
@Override public HookResult onMessage(SMTPSession session, MailEnvelope mail) { Boolean failed = (Boolean) session.getAttachment(MESG_FAILED, State.Transaction); if (failed != null && failed.booleanValue()) { LOGGER.error("Rejected message from {} from {} exceeding system maximum message size of {}", session.getAttachment(SMTPSession.SENDER, State.Transaction), session.getRemoteAddress().getAddress().getHostAddress(), session.getConfiguration().getMaxMessageSize()); return QUOTA_EXCEEDED; } else { return HookResult.DECLINED; } }
/** * Handler method called upon receipt of a EHLO command. Responds with a * greeting and informs the client whether client authentication is * required. * * @param session * SMTP session object * @param argument * the argument passed in with the command by the SMTP client */ private Response doEHLO(SMTPSession session, String argument) { SMTPResponse resp = new SMTPResponse(SMTPRetCode.MAIL_OK, new StringBuilder(session.getConfiguration().getHelloName()).append(" Hello ").append(argument) .append(" [") .append(session.getRemoteAddress().getAddress().getHostAddress()).append("])")); session.setAttachment(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME, State.Connection); processExtensions(session, resp); return resp; }
headerLineBuffer.append("by ").append(session.getConfiguration().getHelloName()).append(" (").append(session.getConfiguration().getSoftwareName()).append(") with ").append(getServiceType(session, heloMode)); headerLineBuffer.append(" ID ").append(session.getSessionID());
/** * Handler method called upon receipt of a QUIT command. This method informs * the client that the connection is closing. * * @param session * SMTP session object * @param argument * the argument passed in with the command by the SMTP client */ private Response doQUIT(SMTPSession session, String argument) { if ((argument == null) || (argument.length() == 0)) { StringBuilder response = new StringBuilder(); response.append( DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.UNDEFINED_STATUS)).append(" ").append( session.getConfiguration().getHelloName()).append( " Service closing transmission channel"); SMTPResponse ret = new SMTPResponse(SMTPRetCode.SYSTEM_QUIT, response); ret.setEndSession(true); return ret; } else { return SYNTAX_ERROR; } }
long maxMessageSize = session.getConfiguration().getMaxMessageSize(); if ((maxMessageSize > 0) && (size > maxMessageSize)) {
} else if (session.getAttachment( SMTPSession.CURRENT_HELO_MODE, State.Connection) == null && session.getConfiguration().useHeloEhloEnforcement()) { return EHLO_HELO_NEEDED; } else if (argument == null if (session.getConfiguration().useAddressBracketsEnforcement() && (!sender.startsWith("<") || !sender.endsWith(">"))) { LOGGER.info("Error parsing sender address: {}: did not start and end with < >", sender);
if (session.getConfiguration().useAddressBracketsEnforcement() && (!recipient.startsWith("<") || !recipient.endsWith(">"))) { LOGGER.info("Error parsing recipient address: Address did not start and end with < >{}", getContext(session, null, recipient)); if (session.getConfiguration().useAddressBracketsEnforcement() || (recipient.startsWith("<") && recipient.endsWith(">"))) { recipient = recipient.substring(1, recipient.length() - 1);
if (session.getConfiguration().getMaxMessageSize() > 0 && newSize.intValue() > session.getConfiguration().getMaxMessageSize()) {