Author: norman
Date: Tue Aug 29 15:13:03 2006
New Revision: 438254
URL: http://svn.apache.org/viewvc?rev=438254&view=rev
Log:
Add fastfail handler to ignore duplicated recipients. See JAMES-576
Added:
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/SupressDuplicateRcptHandler.java
Modified:
james/server/trunk/src/conf/james-smtphandlerchain.xml
Modified: james/server/trunk/src/conf/james-smtphandlerchain.xml
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/conf/james-smtphandlerchain.xml?rev=438254&r1=438253&r2=438254&view=diff
==============================================================================
--- james/server/trunk/src/conf/james-smtphandlerchain.xml (original)
+++ james/server/trunk/src/conf/james-smtphandlerchain.xml Tue Aug 29 15:13:03
2006
@@ -162,6 +162,12 @@
</handler>
-->
+ <!-- This handler ignore duplicated recipients per session. So the email
will get only send on time even -->
+ <!-- if the recipient is specified more then once -->
+ <!--
+ <handler
class="org.apache.james.smtpserver.core.filter.fastfail.SuppressDuplicateRcptHandler"
command="RCPT"/>
+ -->
+
<!-- Load the core command handlers -->
<handler
class="org.apache.james.smtpserver.core.CoreCmdHandlerLoader"></handler>
Added:
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/SupressDuplicateRcptHandler.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/SupressDuplicateRcptHandler.java?rev=438254&view=auto
==============================================================================
---
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/SupressDuplicateRcptHandler.java
(added)
+++
james/server/trunk/src/java/org/apache/james/smtpserver/core/filter/fastfail/SupressDuplicateRcptHandler.java
Tue Aug 29 15:13:03 2006
@@ -0,0 +1,69 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+
+
+
+package org.apache.james.smtpserver.core.filter.fastfail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.james.smtpserver.CommandHandler;
+import org.apache.james.smtpserver.SMTPSession;
+import org.apache.james.util.mail.dsn.DSNStatus;
+import org.apache.mailet.MailAddress;
+
+/**
+ *
+ * This handler can be used to just ignore duplicated recipients.
+ */
+public class SupressDuplicateRcptHandler extends AbstractLogEnabled implements
CommandHandler {
+
+ /**
+ * @see org.apache.james.smtpserver.CommandHandler#getImplCommands()
+ */
+ public Collection getImplCommands() {
+ Collection c = new ArrayList();
+ c.add("RCPT");
+
+ return c;
+ }
+
+ /**
+ * @see org.apache.james.smtpserver.CommandHandler#onCommand(SMTPSession)
+ */
+ public void onCommand(SMTPSession session) {
+ MailAddress rcpt = (MailAddress)
session.getState().get(SMTPSession.CURRENT_RECIPIENT);
+ Collection rcptList = (Collection)
session.getState().get(SMTPSession.RCPT_LIST);
+
+ // Check if the recipient is allready in the rcpt list
+ if(rcptList != null && rcptList.contains(rcpt)) {
+ StringBuffer responseBuffer = new StringBuffer();
+
+ responseBuffer.append("250 " +
DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.ADDRESS_VALID) + " Recipient
<")
+ .append(rcpt.toString()).append("> OK");
+ session.writeResponse(responseBuffer.toString());
+ session.setStopHandlerProcessing(true);
+
+ getLogger().debug("Duplicate recipient not add to recipient list:
" + rcpt.toString());
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]