You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Mark Daring <co...@chello.at> on 2003/11/05 20:12:00 UTC
Re: [PATCH] RemoteDelivery multiple delay times
----- Original Message -----
From: "Andreas Göggerle" <an...@pansoft.de>
To: "'James Developers List'" <se...@james.apache.org>
Cc: <we...@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
Re: [PATCH] RemoteDelivery multiple delay times
Posted by Mark Daring <co...@chello.at>.
----- Original Message -----
From: "Andreas Göggerle" <an...@pansoft.de>
To: "'James Developers List'" <se...@james.apache.org>
Cc: <we...@pansoft.de>
Sent: Friday, November 07, 2003 2:27 PM
Subject: RE: [PATCH] RemoteDelivery multiple delay times
> But why do I need to extend the MimeMessage class? As far as I can see,
> it does nothing new.
That's because of getting rid off all the unwanted default-headers
MimeMessage generates in writeTo(...). Use your original MimeMessage instead
you will see what i mean. You will also get an error message.
But keep in mind with this writeTo version no auto-encoding is done, so you
are responsible for RFC-compliance. As for that matter take a look at
MimeUtiltity.encode(...). This is only necessary when you have non ascii
characters in your text like "Umlaute".
If you dont know your encoding scheme use
MimeUtility.getEncoding(DataHandler dh).
M
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
RE: [PATCH] RemoteDelivery multiple delay times
Posted by Andreas Göggerle <an...@pansoft.de>.
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: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org