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.20.4.5
diff -u -r1.20.4.5 JamesSpoolManager.java
--- src/java/org/apache/james/transport/JamesSpoolManager.java	2 Jun 2003 05:37:27 -0000	1.20.4.5
+++ src/java/org/apache/james/transport/JamesSpoolManager.java	9 Jun 2003 16:41:45 -0000
@@ -425,6 +425,7 @@
                             .append(mail.getName());
                     String exceptionMessage = exceptionMessageBuffer.toString();
                     getLogger().debug(exceptionMessage);
+                    mail.setState(Mail.ERROR);
                     throw new MailetException(exceptionMessage);
                 }
                 StringBuffer logMessageBuffer = null;
@@ -464,8 +465,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/transport/LinearProcessor.java
===================================================================
RCS file: /home/cvspublic/jakarta-james/src/java/org/apache/james/transport/LinearProcessor.java,v
retrieving revision 1.10.4.3
diff -u -r1.10.4.3 LinearProcessor.java
--- src/java/org/apache/james/transport/LinearProcessor.java	2 Jun 2003 05:40:27 -0000	1.10.4.3
+++ src/java/org/apache/james/transport/LinearProcessor.java	9 Jun 2003 16:41:46 -0000
@@ -74,6 +74,7 @@
 import java.util.List;
 import java.util.Random;
 import java.util.Iterator;
+import java.util.Locale;
 
 /**
  * Implements a processor for mails, directing the mail down
@@ -375,7 +376,22 @@
                     verifyMailAddresses(recipients);
                 }
             } catch (MessagingException me) {
-                handleException(me, mail, matcher.getMatcherConfig().getMatcherName());
+                // look in the matcher's mailet's init parameters
+                String onMatchException = ((Mailet) mailets.get(i)).getMailetConfig().getInitParameter("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("match") == 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
@@ -419,7 +435,19 @@
                 // Make sure all the recipients are still MailAddress objects
                 verifyMailAddresses(mail.getRecipients());
             } catch (MessagingException me) {
-                handleException(me, mail, mailet.getMailetConfig().getMailetName());
+                String onMailetException = mailet.getMailetConfig().getInitParameter("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 +510,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 =

