Index: C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java =================================================================== --- C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java (revision 168299) +++ C:/Lab/VOID/projects/james-trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java (working copy) @@ -24,11 +24,12 @@ import org.apache.james.Constants; import org.apache.james.core.MailHeaders; import org.apache.james.core.MailImpl; import org.apache.james.util.Base64; import org.apache.james.util.CRLFTerminatedReader; import org.apache.james.util.CharTerminatedInputStream; import org.apache.james.util.DotStuffingInputStream; import org.apache.james.util.InternetPrintWriter; +import org.apache.james.util.mail.dsn.DSNStatus; import org.apache.james.util.watchdog.BytesReadResetInputStream; import org.apache.james.util.watchdog.Watchdog; import org.apache.james.util.watchdog.WatchdogTarget; @@ -621,13 +643,8 @@ } else { resetState(); state.put(CURRENT_HELO_MODE, COMMAND_HELO); - if (authRequired) { - //This is necessary because we're going to do a multiline response - responseBuffer.append("250-"); - } else { - responseBuffer.append("250 "); - } - responseBuffer.append(theConfigData.getHelloName()) + responseBuffer.append("250 ") + .append(theConfigData.getHelloName()) .append(" Hello ") .append(argument) .append(" (") @@ -636,12 +653,6 @@ .append(remoteIP) .append("])"); responseString = clearResponseBuffer(); - if (authRequired) { - writeLoggedResponse(responseString); - responseString = "250-AUTH LOGIN PLAIN"; - writeLoggedResponse(responseString); - responseString = "250 AUTH=LOGIN PLAIN"; - } writeLoggedFlushedResponse(responseString); } } @@ -656,9 +667,9 @@ private void doEHLO(String argument) { String responseString = null; if (argument == null) { - responseString = "501 Domain address required: " + COMMAND_EHLO; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Domain address required: " + COMMAND_EHLO; writeLoggedFlushedResponse(responseString); } else { resetState(); state.put(CURRENT_HELO_MODE, COMMAND_EHLO); @@ -702,11 +723,11 @@ throws Exception { String responseString = null; if (getUser() != null) { - responseString = "503 User has previously authenticated. " + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" User has previously authenticated. " + " Further authentication is not required!"; writeLoggedFlushedResponse(responseString); } else if (argument == null) { - responseString = "501 Usage: AUTH (authentication type) "; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Usage: AUTH (authentication type) "; writeLoggedFlushedResponse(responseString); } else { String initialResponse = null; @@ -911,11 +932,11 @@ argument = argument.substring(0, colonIndex); } if (state.containsKey(SENDER)) { - responseString = "503 Sender already specified"; + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Sender already specified"; writeLoggedFlushedResponse(responseString); } else if (argument == null || !argument.toUpperCase(Locale.US).equals("FROM") || sender == null) { - responseString = "501 Usage: MAIL FROM:"; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Usage: MAIL FROM:"; writeLoggedFlushedResponse(responseString); } else { sender = sender.trim(); @@ -961,7 +982,7 @@ } } if (!sender.startsWith("<") || !sender.endsWith(">")) { - responseString = "501 Syntax error in MAIL command"; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+" Syntax error in MAIL command"; writeLoggedFlushedResponse(responseString); if (getLogger().isErrorEnabled()) { StringBuffer errorBuffer = @@ -985,7 +1006,7 @@ try { senderAddress = new MailAddress(sender); } catch (Exception pe) { - responseString = "501 Syntax error in sender address"; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX_SENDER)+" Syntax error in sender address"; writeLoggedFlushedResponse(responseString); if (getLogger().isErrorEnabled()) { StringBuffer errorBuffer = @@ -1000,7 +1021,7 @@ } } state.put(SENDER, senderAddress); - responseBuffer.append("250 Sender <") + responseBuffer.append("250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.ADDRESS_OTHER)+" Sender <") .append(sender) .append("> OK"); responseString = clearResponseBuffer(); @@ -1020,7 +1041,7 @@ size = Integer.parseInt(mailOptionValue); } catch (NumberFormatException pe) { // This is a malformed option value. We return an error - String responseString = "501 Syntactically incorrect value for SIZE parameter"; + String responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Syntactically incorrect value for SIZE parameter"; writeLoggedFlushedResponse(responseString); getLogger().error("Rejected syntactically incorrect value for SIZE parameter."); return false; @@ -1036,7 +1057,7 @@ long maxMessageSize = theConfigData.getMaxMessageSize(); if ((maxMessageSize> 0) && (size> maxMessageSize)) { // Let the client know that the size limit has been hit. - String responseString = "552 Message size exceeds fixed maximum message size"; + String responseString = "552 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_MSG_TOO_BIG)+" Message size exceeds fixed maximum message size"; writeLoggedFlushedResponse(responseString); StringBuffer errorBuffer = new StringBuffer(256) @@ -1077,11 +1098,11 @@ argument = argument.substring(0, colonIndex); } if (!state.containsKey(SENDER)) { - responseString = "503 Need MAIL before RCPT"; + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Need MAIL before RCPT"; writeLoggedFlushedResponse(responseString); } else if (argument == null || !argument.toUpperCase(Locale.US).equals("TO") || recipient == null) { - responseString = "501 Usage: RCPT TO:"; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_SYNTAX)+" Usage: RCPT TO:"; writeLoggedFlushedResponse(responseString); } else { Collection rcptColl = (Collection) state.get(RCPT_LIST); @@ -1122,7 +1143,7 @@ optionTokenizer = null; } if (!recipient.startsWith("<") || !recipient.endsWith(">")) { - responseString = "501 Syntax error in parameters or arguments"; + responseString = "501 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_SYNTAX)+" Syntax error in parameters or arguments"; writeLoggedFlushedResponse(responseString); if (getLogger().isErrorEnabled()) { StringBuffer errorBuffer = @@ -1143,7 +1164,12 @@ try { recipientAddress = new MailAddress(recipient); } catch (Exception pe) { - responseString = "501 Syntax error in recipient address"; + /* + * from RFC2822; + * 553 Requested action not taken: mailbox name not allowed + * (e.g., mailbox syntax incorrect) + */ + responseString = "553 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.ADDRESS_SYNTAX)+" Syntax error in recipient address"; writeLoggedFlushedResponse(responseString); if (getLogger().isErrorEnabled()) { @@ -1162,8 +1188,8 @@ // authenticated else reject. if (getUser() == null) { String toDomain = recipientAddress.getHost(); if (!theConfigData.getMailServer().isLocalServer(toDomain)) { - responseString = "530 Authentication Required"; + responseString = "530 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Authentication Required"; writeLoggedFlushedResponse(responseString); getLogger().error("Rejected message - authentication is required for mail request"); return; @@ -1177,7 +1203,7 @@ if ((!authUser.equals(senderAddress.getUser())) || (!theConfigData.getMailServer().isLocalServer(senderAddress.getHost()))) { - responseString = "503 Incorrect Authentication for Specified Email Address"; + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Incorrect Authentication for Specified Email Address"; writeLoggedFlushedResponse(responseString); if (getLogger().isErrorEnabled()) { StringBuffer errorBuffer = @@ -1195,7 +1221,7 @@ } else if (!relayingAllowed) { String toDomain = recipientAddress.getHost(); if (!theConfigData.getMailServer().isLocalServer(toDomain)) { - responseString = "550 - Requested action not taken: relaying denied"; + responseString = "550 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Requested action not taken: relaying denied"; writeLoggedFlushedResponse(responseString); getLogger().error("Rejected message - " + remoteIP + " not authorized to relay to " + toDomain); return; @@ -1203,7 +1229,7 @@ } rcptColl.add(recipientAddress); state.put(RCPT_LIST, rcptColl); - responseBuffer.append("250 Recipient <") + responseBuffer.append("250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.ADDRESS_VALID)+" Recipient <") .append(recipient) .append("> OK"); responseString = clearResponseBuffer(); @@ -1218,7 +1244,7 @@ * @param argument the argument passed in with the command by the SMTP client */ private void doNOOP(String argument) { - String responseString = "250 OK"; + String responseString = "250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.UNDEFINED_STATUS)+" OK"; writeLoggedFlushedResponse(responseString); } @@ -1231,10 +1257,10 @@ private void doRSET(String argument) { String responseString = ""; if ((argument == null) || (argument.length() == 0)) { - responseString = "250 OK"; + responseString = "250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.UNDEFINED_STATUS)+" OK"; resetState(); } else { - responseString = "500 Unexpected argument provided with RSET command"; + responseString = "500 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Unexpected argument provided with RSET command"; } writeLoggedFlushedResponse(responseString); } @@ -1249,14 +1275,14 @@ private void doDATA(String argument) { String responseString = null; if ((argument != null) && (argument.length()> 0)) { - responseString = "500 Unexpected argument provided with DATA command"; + responseString = "500 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Unexpected argument provided with DATA command"; writeLoggedFlushedResponse(responseString); } if (!state.containsKey(SENDER)) { - responseString = "503 No sender specified"; + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" No sender specified"; writeLoggedFlushedResponse(responseString); } else if (!state.containsKey(RCPT_LIST)) { - responseString = "503 No recipients specified"; + responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" No recipients specified"; writeLoggedFlushedResponse(responseString); } else { responseString = "354 Ok Send data ending with ."; @@ -1301,7 +1327,7 @@ state.put(MESG_FAILED, Boolean.TRUE); // then let the client know that the size // limit has been hit. - responseString = "552 Error processing message: " + responseString = "552 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_MSG_TOO_BIG)+" Error processing message: " + e.getMessage(); StringBuffer errorBuffer = new StringBuffer(256) @@ -1315,7 +1341,7 @@ .append(theConfigData.getMaxMessageSize()); getLogger().error(errorBuffer.toString()); } else { - responseString = "451 Error processing message: " + responseString = "451 "+DSNStatus.getStatus(DSNStatus.TRANSIENT,DSNStatus.UNDEFINED_STATUS)+" Error processing message: " + me.getMessage(); getLogger().error("Unknown error occurred while processing DATA.", me); } @@ -1332,7 +1358,7 @@ } } resetState(); - responseString = "250 Message received"; + responseString = "250 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.CONTENT_OTHER)+" Message received"; writeLoggedFlushedResponse(responseString); } } @@ -1478,12 +1504,12 @@ String responseString = ""; if ((argument == null) || (argument.length() == 0)) { - responseBuffer.append("221 ") + responseBuffer.append("221 "+DSNStatus.getStatus(DSNStatus.SUCCESS,DSNStatus.UNDEFINED_STATUS)+" ") .append(theConfigData.getHelloName()) .append(" Service closing transmission channel"); responseString = clearResponseBuffer(); } else { - responseString = "500 Unexpected argument provided with QUIT command"; + responseString = "500 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_INVALID_ARG)+" Unexpected argument provided with QUIT command"; } writeLoggedFlushedResponse(responseString); } @@ -1496,7 +1522,7 @@ * @param argument the argument passed in with the command by the SMTP client */ private void doVRFY(String argument) { - String responseString = "502 VRFY is not supported"; + String responseString = "502 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_NOT_CAPABLE)+" VRFY is not supported"; writeLoggedFlushedResponse(responseString); } @@ -1509,7 +1535,7 @@ */ private void doEXPN(String argument) { - String responseString = "502 EXPN is not supported"; + String responseString = "502 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_NOT_CAPABLE)+" EXPN is not supported"; writeLoggedFlushedResponse(responseString); } @@ -1522,7 +1548,7 @@ */ private void doHELP(String argument) { - String responseString = "502 HELP is not supported"; + String responseString = "502 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.SYSTEM_NOT_CAPABLE)+" HELP is not supported"; writeLoggedFlushedResponse(responseString); } @@ -1534,7 +1560,7 @@ * @param argument the argument passed in with the command by the SMTP client */ private void doUnknownCmd(String command, String argument) { - responseBuffer.append("500 ") + responseBuffer.append("500 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.UNDEFINED_STATUS)+" ") .append(theConfigData.getHelloName()) .append(" Syntax error, command unrecognized: ") .append(command);

AltStyle によって変換されたページ (->オリジナル) /