@Override protected Response doFilterChecks(SMTPSession session, String command, String parameters) { session.setAttachment("CURR_COMMAND", command, State.Transaction); return null; }
@Override protected Response doFilterChecks(SMTPSession session, String command, String parameters) { session.resetState(); if (parameters == null) { return DOMAIN_REQUIRED; } else { // store provided name session.setAttachment(SMTPSession.CURRENT_HELO_NAME, parameters, State.Connection); return null; } }
@Override protected Response doFilterChecks(SMTPSession session, String command, String parameters) { session.resetState(); if (parameters == null) { return DOMAIN_ADDRESS_REQUIRED; } else { // store provided name session.setAttachment(SMTPSession.CURRENT_HELO_NAME, parameters, State.Connection); return null; } }
/** * Check if EHLO/HELO is resolvable * * @param session * The SMTPSession * @param argument * The argument */ protected void checkEhloHelo(SMTPSession session, String argument) { if (isBadHelo(session, argument)) { session.setAttachment(BAD_EHLO_HELO, "true", State.Transaction); } }
@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 onCommand(SMTPSession session, Request request) { Response response = super.onCommand(session, request); // Check if the response was not ok if (response.getRetCode().equals(SMTPRetCode.MAIL_OK) == false) { // cleanup the session session.setAttachment(SMTPSession.SENDER, null, State.Transaction); } return response; }
session.setAttachment(URBLSERVER, uRblServer, State.Transaction); session.setAttachment(LISTED_DOMAIN, target, State.Transaction);
/** * 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; }
@Override public final Response onLine(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) { if (session.getAttachment(HEADERS_COMPLETE, State.Transaction) == null) { if (line.remaining() == 2) { if (line.get() == '\r' && line.get() == '\n') { line.rewind(); Response response = onSeparatorLine(session, line, next); session.setAttachment(HEADERS_COMPLETE, Boolean.TRUE, State.Transaction); return response; } line.rewind(); } return onHeadersLine(session, line, next); } return onBodyLine(session, line, next); }
session.setAttachment(SPF_HEADER, result.getHeaderText(), State.Transaction); explanation = "Block caused by an invalid SPF record"; session.setAttachment(SPF_DETAIL, explanation, State.Transaction); session.setAttachment(SPF_BLOCKLISTED, "true", State.Transaction); session.setAttachment(SPF_TEMPBLOCKLISTED, "true", State.Transaction);
session.setAttachment(MESG_SIZE, Integer.valueOf(size), State.Transaction);
CURRENT_RECIPIENT, State.Transaction); rcptColl.add(recipientAddress); session.setAttachment(SMTPSession.RCPT_LIST, rcptColl, State.Transaction); StringBuilder response = new StringBuilder(); response
session.setAttachment(RBL_DETAIL_MAIL_ATTRIBUTE_NAME, blocklistedDetail, State.Connection); session.setAttachment(RBL_BLOCKLISTED_MAIL_ATTRIBUTE_NAME, "true", State.Connection); return; } else {
/** * Handler method called upon receipt of a DATA command. * Reads in message data, creates header, and delivers to * mail server service for delivery. * * @param session SMTP session object * @param argument the argument passed in with the command by the SMTP client */ @SuppressWarnings("unchecked") protected Response doDATA(SMTPSession session, String argument) { MaybeSender sender = (MaybeSender) session.getAttachment(SMTPSession.SENDER, ProtocolSession.State.Transaction); MailEnvelope env = createEnvelope(session, sender, new ArrayList<>((Collection<MailAddress>) session.getAttachment(SMTPSession.RCPT_LIST, ProtocolSession.State.Transaction))); session.setAttachment(MAILENV, env,ProtocolSession.State.Transaction); session.pushLineHandler(lineHandler); return DATA_READY; }
@Override protected Response onHeadersLine(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) { if (getLocation() == Location.Prefix && session.getAttachment(headersPrefixAdded, State.Transaction) == null) { session.setAttachment(headersPrefixAdded, Boolean.TRUE, State.Transaction); return addHeaders(session, line, next); } return super.onHeadersLine(session, line, next); }
@Override protected Response onSeparatorLine(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) { if (getLocation() == Location.Suffix && session.getAttachment(headersSuffixAdded, State.Transaction) == null) { session.setAttachment(headersSuffixAdded, Boolean.TRUE, State.Transaction); return addHeaders(session, line, next); } return super.onSeparatorLine(session, line, next); }
session.setAttachment("CURRENT_SIZE", newSize, State.Transaction); session.setAttachment(MESG_FAILED, Boolean.TRUE, State.Transaction);
/** * Handler method called upon receipt of a DATA command. Reads in message * data, creates header, and delivers to mail server service for delivery. * * @param session SMTP session object * @param argument the argument passed in with the command by the SMTP client */ @Override protected SMTPResponse doDATA(SMTPSession session, String argument) { try { MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(MailImpl.getId()); session.setAttachment(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE, mmiss, State.Transaction); } catch (Exception e) { LOGGER.warn("Error creating mimemessagesource for incoming data", e); return new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unexpected error preparing to receive DATA."); } // out = new PipedOutputStream(messageIn); session.pushLineHandler(getLineHandler()); return new SMTPResponse(SMTPRetCode.DATA_READY, "Ok Send data ending with <CRLF>.<CRLF>"); }
session.setAttachment(SMTPConstants.MAIL, mail, State.Transaction);
@Override public HookResult doUnknown(SMTPSession session, String command) { Integer count = (Integer) session.getAttachment(UNKOWN_COMMAND_COUNT, State.Transaction); if (count == null) { count = 1; } else { count++; } session.setAttachment(UNKOWN_COMMAND_COUNT, count, State.Transaction); if (count > maxUnknown) { return HookResult.builder() .hookReturnCode(HookReturnCode.disconnected(HookReturnCode.Action.DENY)) .smtpReturnCode("521") .smtpDescription("Closing connection as too many unknown commands received") .build(); } else { return HookResult.DECLINED; } }