james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Daring" <cog...@chello.at>
Subject Re: [PATCH] RemoteDelivery multiple delay times
Date Wed, 05 Nov 2003 19:12:00 GMT

----- Original Message -----
From: "Andreas Göggerle" <andreas.goeggerle@pansoft.de>
To: "'James Developers List'" <server-dev@james.apache.org>
Cc: <werling@pansoft.de>
Sent: Thursday, October 30, 2003 3:30 PM
Subject: RE: [PATCH] RemoteDelivery multiple delay times

> 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

Servus Andreas,

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"

and your own MimeMessage class maybe like this:

"...
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();
  }

 }".

If you want to test it, here is a suggestion:

"...
  private void test() {
    try {
      MimeMultipart mp = new MimeMultipart();
      MimeBodyPart body1 = new MimeBodyPart();

      body1.setContent("Plain TEXT","text/plain");
      mp.addBodyPart(body1);

      Session session = Session.getDefaultInstance(System.getProperties());
      MimeBodyPart body2 = new MimeBodyPart();
      Message m = new DSNMessage();
      m.setContent(new
String("DSN-MESSAGE").getBytes(),"message/delivery-status");
      body2.setContent(m,"message/delivery-status");
      mp.addBodyPart(body2);

// Andreas if you want to support type text/rfc822-headers you would
definetly repeat the steps above

      MimeBodyPart body3 = new MimeBodyPart();
      body3.setContent("RFC822-HEADER","text/rfc822-headers");
      mp.addBodyPart(body3);
      Message msg = new MimeMessage(session);

      ContentType cType = new ContentType();
      cType.setPrimaryType("multipart");
      cType.setSubType("report");
      cType.setParameter("report-type", "delivery-status");
      String contentType = cType.toString();
      msg.setContent(mp,contentType);
      msg.saveChanges();
      msg.writeTo(System.out);
    }
"
Hope this helps.

M


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message