RE: [PATCH] RemoteDelivery and new DSNBounce Mailet

2003-12-02 Thread Andreas Göggerle
;
 * /CODE/PRE
 *
 *
 * @author Andreas Göggerle [EMAIL PROTECTED]
 *
 * @see org.apache.james.transport.mailets.AbstractNotify
 */



public class DSNBounce extends AbstractNotify {

///**
// *
// * @author Andreas Göggerle [EMAIL PROTECTED]
// */
//
//public class DSNMessage extends MimeMessage {
//
//  private String type = ;
//
//  public DSNMessage() {
//super(Session.getDefaultInstance(System.getProperties(), null));
//  }
//
//  public void setContent(Object o, String type) throws MessagingException {
//this.type = type;
//super.content = (byte[])o;
//  }
//
//  public void writeContentTo(OutputStream outs)
// throws java.io.IOException, MessagingException {
// outs.write(super.content);
// outs.flush();
//  }
//
//  public void writeTo(OutputStream outs, String as[])
//  throws IOException, MessagingException
//  {
//  outs.write(super.content);
//  outs.flush();
//  }
//
// }


/**
 * Constants and getters for RFC 3463 Enhanced Mail System Status Codes
 *
 * I suggest do extract this inner class for future use in the smtp-handler
 *
 * @author Andreas Göggerle [EMAIL PROTECTED]
 */
public static class DSNStatus {
// status code classes
/**
 * Success
 */
public static final int SUCCESS = 2;

/**
 * Persistent Transient Failure
 */
public static final int TRANSIENT = 4;

/**
 * Permanent Failure
 */
public static final int PERMANENT = 5;

// subjects and details

/**
 * Other or Undefined Status
 */
public static final int UNDEFINED = 0;

/**
 * Other undefined status
 */
public static final String UNDEFINED_STATUS = 0.0;

/**
 * Addressing Status
 */
public static final int ADDRESS = 1;

/**
 * Other address status
 */
public static final String ADDRESS_OTHER = 1.0;

/**
 * Bad destination mailbox address
 */
public static final String ADDRESS_MAILBOX = 1.1;

/**
 * Bad destination system address
 */
public static final String ADDRESS_SYSTEM = 1.2;

/**
 * Bad destination mailbox address syntax
 */
public static final String ADDRESS_SYNTAX = 1.3;

/**
 * Destination mailbox address ambiguous
 */
public static final String ADDRESS_AMBIGUOUS = 1.4;

/**
 * Destination Address valid
 */
public static final String ADDRESS_VALID = 1.5;

/**
 * Destimation mailbox has moved, no forwarding address
 */
public static final String ADDRESS_MOVED = 1.6;

/**
 * Bad sender's mailbox address syntax
 */
public static final String ADDRESS_SYNTAX_SENDER = 1.7;

/**
 * Bad sender's system address
 */
public static final String ADDRESS_SYSTEM_SENDER = 1.8;


/**
 * Mailbox Status
 */
public static final int MAILBOX = 2;

/**
 * Other or Undefined Mailbox Status
 */
public static final String MAILBOX_OTHER = 2.0;

/**
 * Mailbox disabled, not accepting messages
 */
public static final String MAILBOX_DISABLED = 2.1;

/**
 * Mailbox full
 */
public static final String MAILBOX_FULL = 2.2;

/**
 * Message length exceeds administrative limit
 */
public static final String MAILBOX_MSG_TOO_BIG = 2.3;

/**
 * Mailing list expansion problem
 */
public static final String MAILBOX_LIST_EXPANSION = 2.4;


/**
 * Mail System Status
 */
public static final int SYSTEM = 3;

/**
 * Other or undefined mail system status
 */
public static final String SYSTEM_OTHER = 3.0;

/**
 * Mail system full
 */
public static final String SYSTEM_FULL = 3.1;

/**
 * System not accepting messages
 */
public static final String SYSTEM_NOT_ACCEPTING = 3.2;

/**
 * System not capable of selected features
 */
public static final String SYSTEM_NOT_CAPABLE = 3.3;

/**
 * Message too big for system
 */
public static final String SYSTEM_MSG_TOO_BIG = 3.4;

/**
 * System incorrectly configured
 */
public static final String SYSTEM_CFG_ERROR = 3.5;


/**
 * Network and Routing Status
 */
public static final int NETWORK = 4;

/**
 * Other or undefined network or routing status
 */
public static final String NETWORK_OTHER = 4.0

[PATCH] RemoteDelivery and new DSNBounce Mailet

2003-11-27 Thread Andreas Göggerle
Hi,

finaly I got time to get things ready.

This Patch to RemoteDelivery introduces a new parameter dsnProcessor.
Here you can specify a processor, where DSN conform Bounces are created.
If this parameter is missing, mails get bounced the old way.

Here is a configuration example:

processor name=transport
[...]
   mailet match=All class=RemoteDelivery
   [...]
  !-- Processor for DSN creation --
  dsnProcessordsn/dsnProcessor
   /mailet
/processor

processor name=dsn
   mailet match=All class=DSNBounce
  !-- sender defaults to postmaster --
  sender [EMAIL PROTECTED] /sender
!-- Subject Prefix (default=Re:) --
  prefix ERROR: /prefix
  passThrough false /passThrough
   /mailet
/processor

The DSNBounce Mailet creates Bounce Mails in the format specified by RFCs
3462
to 3464. There is only one discrepancy: the MIME-type text/plain is used
for
the status-report part, instead of message/delivery-status.
JavaMail doesn't support message/delivery-status.

Andreas


***
Mail: [EMAIL PROTECTED]
Web: www.pansoft.de
Tel.: +49 (0)721 62532 - 16
Fax: +49 (0)721 62532 - 44

PANSOFT GmbH
Tullastr. 28
76131 Karlsruhe
***
Index: RemoteDelivery.java
===
RCS file: 
/home/cvspublic/james-server/src/java/org/apache/james/transport/mailets/RemoteDelivery.java,v
retrieving revision 1.51
diff -u -r1.51 RemoteDelivery.java
--- RemoteDelivery.java 18 Jun 2003 15:59:44 -  1.51
+++ RemoteDelivery.java 27 Nov 2003 16:21:02 -
@@ -89,6 +89,7 @@
 import org.apache.mailet.GenericMailet;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
+import org.apache.mailet.MailetContext;
 import org.apache.mailet.MailetContextConstants;
 import org.apache.mailet.SpoolRepository;
 
@@ -138,6 +139,7 @@
 private Collection deliveryThreads = new Vector();
 
 private volatile boolean destroyed = false; //Flag that the run method will check 
and end itself if set to true
+private String dsnProcessor = null; // the processor for creating DSNs
 
 /**
  * Initialize the mailet
@@ -174,6 +176,7 @@
 log(Invalid timeout setting:  + getInitParameter(timeout));
 }
 sendPartial = (getInitParameter(sendpartial) == null) ? false : new 
Boolean(getInitParameter(sendpartial)).booleanValue();
+dsnProcessor = getInitParameter(dsnProcessor);
 
 String gateway = getInitParameter(gateway);
 gatewayPort = getInitParameter(gatewayPort);
@@ -543,7 +546,25 @@
 log(logBuffer.toString());
 }
 }
-bounce(mail, ex);
+
+if (dsnProcessor != null) {
+// do the new DSN bounce
+// setting attributes for DSN mailet
+mail.setAttribute(DSN-error, ex);
+mail.setState(dsnProcessor);
+// re-insert the mail into the spool for getting it passed to the 
dsn-processor
+MailetContext mc = getMailetContext();
+try {
+mc.sendMail(mail);
+} catch (MessagingException e) {
+// we shouldn't get an exception, because the mail was already 
processed
+log(Exception re-inserting failed mail: , e);
+}
+} else {
+// do an old style bounce
+bounce(mail, ex);
+}
+
 return true;
 }
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

RE: private vs. protected access

2003-11-07 Thread Andreas Göggerle
Noel J. Bergman wrote:
 Søren Hilmer wrote:
  I agree that Andreas's DSN solution should make it into
  the next build. My only concern is that we get yet
  another processor with special meaning, besides root and
  error.  I suggest that we make the processor name a
  parameter to RemoteDelivery.

  DSNProcessordsn/DSNProcessor

 I absolutely agree.  Isnt' that what we've been discussing?
 I'm almost
 certain that I mentioned that in one of my e-mails.

   --- Noel

Yes you mentioned this. An I'll implement it as a parameter before I
submit the Mailet and a Patch for RemoteDelivery.

But be patient, I'm very busy with other things at the moment.

Andreas


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [PATCH] RemoteDelivery multiple delay times

2003-11-07 Thread Andreas Göggerle

Mark Daring wrote:
 you dont need to write your own DataHandler, just use what 
 allready exists.
 You could use the default Handler of the 
 message/rfc822-messages and extend
 the MimeMessage class.
 For example your mailcap-file (take a look at 
 mail.jar/META-INF/mailcap)
 would then look something like this:
 ...
 message/rfc822;; 
 x-java-content-handler=com.sun.mail.handlers.message_rfc822
 message/delivery-status;;
 x-java-content-handler=com.sun.mail.handlers.message_rfc822

I'll test this as soon as I get a little time for it.

But why do I need to extend the MimeMessage class? As far as I can see, 
it does nothing new. 

Thanks for your help!
Andreas

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [PATCH] RemoteDelivery multiple delay times

2003-10-30 Thread Andreas Göggerle
Hi,

I wrote a DSNBounce Mailet (extending Vincenzos AbstractNotify) that
produces Delivery Status Notifications using the format described in RFC
3462 - RFC 3464.
This Mailet gets the failed Message with the Exception that occured attached
as Attribute.

Therefor I replaced the call of bounce(mail, ex); at the end of
RemoteDeliverys failMessage() by the following:

// setting attributes for DSN mailet
mail.setAttribute(DSN-error, ex);
mail.setState(dsn);
// re-insert the mail into the spool for getting it passed to the
DSN-processor
MailetContext mc = getMailetContext();
try {
mc.sendMail(mail);
} catch (MessagingException e) {
// we shouldn't get an exception, because the mail was already processed
log(Exception re-inserting failed mail: , e);
}
// bounce() is no longer needed
//bounce(mail, ex);

so the failed message isn't bounced, but goes to a DSN processor, where the
DSNBounce Mailet does the Bounce and ghosts the original Mail.

in my config.xml I defined a processor dsn like this:
!-- the DSN processor --
processor name=dsn
   !-- all mails go to the DNSBounce Mailet --
   mailet match=All class=DSNBounce
  !-- The sender defaults to the postmaster address --
  sender [EMAIL PROTECTED] /sender
  !-- Subject prefix, defaults to Re: --
  prefix ERROR: /prefix
  !-- attachment: how should the original mail be attached? --
  !-- MESSAGE or NONE, defaults to MESSAGE --
  attachment MESSAGE /attachment
  !-- passThrough, defaults to false --
  passThrough false /passThrough
  !-- debug, default = false --
  debug false /debug
   /mailet
/processor

My DSNBounce Mailet could easy be re-written to handle all DSNs, not only
Bounces like it does at the moment. delayed-reports and success-reports
may be done in this way. But therefor more information must be providet to
the Mailet. I would suggest a DSN-specific Attribute that holds an Enhanced
Mail System Status Code (RFC3463). This should be set either by the
SMTP-handler (which could implement RFC3461 - SMTP service extension for
DSN) or by RemoteDelivery. At the moment my Mailet is guessing this Status
Code using the exception catched in RemoteDelivery.

But i still have one (minor?) problem with my Mailet to be RFC conform:
JavaMail 1.3.1 doesn't support the MIME-Type message/delivery-status and I
don't have the time to look at the JavaBeans Activation Framework for
writing an own DataContentHandler for this MIME-Type. At the monent I send
the delivery-report as MIME-Type text/plain. If someone is willing to do
the DataContentHandler or if you want to accept it even if it's not 100% RFC
conform I can contribute the current Mailet.

Andreas


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problem with MIME type message/delivery-status

2003-09-25 Thread Andreas Göggerle
Hi everyone,

while writing a DSNBounce mailet that produces RFC3464 conform
Delivery Status Notifications I encountered a problem with the
MIME type message/delivery-status.
When I try to send a multipart mail with a bodypart having this
MIME type, I get the follwing runtime exception:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
message/delivery-status
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:841)
at javax.activation.DataHandler.writeTo(DataHandler.java:295)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:635)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:233)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:68)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:839)
at javax.activation.DataHandler.writeTo(DataHandler.java:295)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1089)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1527)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1503)
at org.apache.james.core.MailImpl.writeMessageTo(MailImpl.java:444)
at
org.apache.james.mailrepository.AvalonMailRepository.store(AvalonMailReposit
ory.java:329)
at org.apache.james.James.sendMail(James.java:492)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.avalon.phoenix.components.application.BlockInvocationHandler.invo
ke(BlockInvocationHandler.java:92)
at $Proxy9.sendMail(Unknown Source)
at org.apache.james.transport.mailets.DSNBounce.service(DSNBounce.java:241)
at
org.apache.james.transport.LinearProcessor.service(LinearProcessor.java:440)
at
org.apache.james.transport.JamesSpoolManager.process(JamesSpoolManager.java:
396)
at
org.apache.james.transport.JamesSpoolManager.run(JamesSpoolManager.java:332)
at
org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnab
le.java:90)
at org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:136)
exception! javax.mail.MessagingException: Exception spooling message:
Exception caught while storing Message Container:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
message/delivery-status;
  nested exception is:
java.lang.RuntimeException: Exception caught while storing Message
Container: javax.activation.UnsupportedDataTypeException: no object DCH for
MIME type message/delivery-status

This is how I set the MIME type:

MimeBodyPart dsn = new MimeBodyPart();
MimeMessage dsnMessage = new
MimeMessage(Session.getDefaultInstance(System.getProperties(), null));
StringWriter sout = new StringWriter();
[...]
dsnMessage.setText(sout.toString());
dsnMessage.saveChanges();
dsn.setContent(dsnMessage, message/delivery-status);

I'm using sun's mail.jar version 1.3.1 and activation.jar version 1.0.2
I'm running james-3.0a1 from CVS HEAD on a Win2000 OS


How can I solve this problem? Seems I have to somehow register
a DataContentHandler for the MIME type, but I have no idea how/where
to do so. Any help would be appreciated.

Thanks in advance
   Andreas


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]