Index: src/java/org/apache/james/transport/LinearProcessor.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/java/org/apache/james/transport/LinearProcessor.java,v
retrieving revision 1.19
diff -u -r1.19 LinearProcessor.java
--- src/java/org/apache/james/transport/LinearProcessor.java	2 Jun 2003 06:19:41 -0000	1.19
+++ src/java/org/apache/james/transport/LinearProcessor.java	16 Jun 2003 10:46:07 -0000
@@ -96,6 +96,9 @@
  *  &lt;/processor&gt;
  *
  * Note that the 'onerror' attribute is not yet supported.
+ *
+ * <P>CVS $Id$</P>
+ * @version 2.2.0
  */
 public class LinearProcessor
     extends AbstractLogEnabled
@@ -376,7 +379,23 @@
                     verifyMailAddresses(recipients);
                 }
             } catch (MessagingException me) {
-                handleException(me, mail, matcher.getMatcherConfig().getMatcherName());
+                // look in the matcher's mailet's init attributes
+                MailetConfig mailetConfig = ((Mailet) mailets.get(i)).getMailetConfig();
+                String onMatchException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMatchException");
+                if (onMatchException == null) {
+                    onMatchException = Mail.ERROR;
+                } else {
+                    onMatchException = onMatchException.trim().toLowerCase(Locale.US);
+                }
+                if (onMatchException.compareTo("nomatch") == 0) {
+                    //In case the matcher returned null, create an empty Collection
+                    recipients = new ArrayList(0);
+                } else if (onMatchException.compareTo("matchall") == 0) {
+                    recipients = mail.getRecipients();
+                    // no need to verify addresses
+                } else {
+                    handleException(me, mail, matcher.getMatcherConfig().getMatcherName(), onMatchException);
+                }
             }
             // Split the recipients into two pools.  notRecipients will contain the
             // recipients on the message that the matcher did not return.
@@ -419,7 +438,20 @@
                 // Make sure all the recipients are still MailAddress objects
                 verifyMailAddresses(mail.getRecipients());
             } catch (MessagingException me) {
-                handleException(me, mail, mailet.getMailetConfig().getMailetName());
+                MailetConfig mailetConfig = mailet.getMailetConfig();
+                String onMailetException = ((MailetConfigImpl) mailetConfig).getInitAttribute("onMailetException");
+                if (onMailetException == null) {
+                    onMailetException = Mail.ERROR;
+                } else {
+                    onMailetException = onMailetException.trim().toLowerCase(Locale.US);
+                }
+                if (onMailetException.compareTo("ignore") == 0) {
+                    // ignore the exception and continue
+                    // this option should not be used if the mail object can be changed by the mailet
+                    verifyMailAddresses(mail.getRecipients());
+                } else {
+                    handleException(me, mail, mailet.getMailetConfig().getMailetName(), onMailetException);
+                }
             }
 
             // See if the state was changed by the mailet
@@ -482,12 +514,13 @@
      * @param me the exception to be handled
      * @param mail the mail being processed when the exception was generated
      * @param offendersName the matcher or mailet than generated the exception
+     * @param nextState the next state to set
      *
      * @throws MessagingException thrown always, rethrowing the passed in exception
      */
-    private void handleException(MessagingException me, Mail mail, String offendersName) throws MessagingException {
+    private void handleException(MessagingException me, Mail mail, String offendersName, String nextState) throws MessagingException {
         System.err.println("exception! " + me);
-        mail.setState(Mail.ERROR);
+        mail.setState(nextState);
         StringWriter sout = new StringWriter();
         PrintWriter out = new PrintWriter(sout, true);
         StringBuffer exceptionBuffer =
Index: src/java/org/apache/james/transport/JamesSpoolManager.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/java/org/apache/james/transport/JamesSpoolManager.java,v
retrieving revision 1.32
diff -u -r1.32 JamesSpoolManager.java
--- src/java/org/apache/james/transport/JamesSpoolManager.java	28 Apr 2003 14:00:40 -0000	1.32
+++ src/java/org/apache/james/transport/JamesSpoolManager.java	16 Jun 2003 10:46:08 -0000
@@ -89,8 +89,8 @@
  * processor, and removing them from the spool when processing is
  * complete.
  *
- *
- * @version This is $Revision: 1.32 $
+ * <P>CVS $Id$</P>
+ * @version 2.2.0
  */
 public class JamesSpoolManager
     extends AbstractLogEnabled
@@ -383,6 +383,7 @@
                             .append(mail.getName());
                     String exceptionMessage = exceptionMessageBuffer.toString();
                     getLogger().debug(exceptionMessage);
+                    mail.setState(Mail.ERROR);
                     throw new MailetException(exceptionMessage);
                 }
                 StringBuffer logMessageBuffer = null;
@@ -417,8 +418,7 @@
                     mail.setState(Mail.GHOST);
                     mail.setErrorMessage(e.getMessage());
                 } else {
-                    //We got an error... send it to the error processor
-                    mail.setState(Mail.ERROR);
+                    //We got an error... send it to the requested processor
                     mail.setErrorMessage(e.getMessage());
                 }
             }
Index: src/java/org/apache/james/core/MailetConfigImpl.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/java/org/apache/james/core/MailetConfigImpl.java,v
retrieving revision 1.7
diff -u -r1.7 MailetConfigImpl.java
--- src/java/org/apache/james/core/MailetConfigImpl.java	8 Mar 2003 21:14:01 -0000	1.7
+++ src/java/org/apache/james/core/MailetConfigImpl.java	16 Jun 2003 10:46:54 -0000
@@ -68,6 +68,8 @@
 /**
  * Implements the configuration object for a Mailet.
  *
+ * <P>CVS $Id$</P>
+ * @version 2.2.0
  */
 public class MailetConfigImpl implements MailetConfig {
 
@@ -133,6 +135,22 @@
     public Iterator getInitParameterNames() {
         throw new UnsupportedOperationException("Not yet implemented");
         //return params.keySet().iterator();
+    }
+
+    /**
+     * Get the value of an (XML) attribute stored in this MailetConfig.
+     *
+     * @param name the name of the attribute whose value is to be retrieved.
+     *
+     * @return the attribute value
+     */
+    public String getInitAttribute(String name) {
+        try {
+            return configuration.getAttribute(name);
+        } catch (ConfigurationException ce) {
+            throw new RuntimeException("Embedded configuration exception was: " + ce.getMessage());
+        }
+
     }
 
     /**

