The current AddFooter mailet is unable to successfully add its footer to more complex mail messages:  specifically, any MimeMessage that has nested MimeMultiparts.
 
These kinds of email messages may result when a user decides to use embedded html elements with their email.  For instance, Outlook Express has a Stationary feature that causes these complex MimeMessages to occur.
 
I came across this scenario, while building a [slightly] more advanced list serv mailet that i hope to donate either to mailet.org or the james project.  I wanted to embed a standard mailing list footer (like you see with the Jakarta mailing lists), and ensure that the footer is included regardless of the type of mail sent to the list.
 
Regards,
--mark imel
 
BTW: This is my first time submitting a patch to an apache project, i apologize if i messed up the cvs diff file.  I'd be more than happy to send the modified AddFooter if preferred, or regenerate the diff file if necessary.
Index: src/java/org/apache/james/transport/mailets/AddFooter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-james/src/java/org/apache/james/transport/mailets/AddFooter.java,v
retrieving revision 1.5
diff -u -r1.5 AddFooter.java
--- src/java/org/apache/james/transport/mailets/AddFooter.java  12 Jan 2003 22:38:32 
-0000      1.5
+++ src/java/org/apache/james/transport/mailets/AddFooter.java  14 Feb 2003 19:50:31 
+-0000
@@ -60,7 +60,7 @@
                 attachFooter(part);
                 //We have to do this because of a bug in JavaMail (ref id 4404733)
                 message.setContent(multipart);
-            } else if (message.isMimeType("multipart/alternative")) {
+            } else {
                 //Find the HTML and text message types and add to each
                 MimeMultipart multipart = (MimeMultipart)message.getContent();
                 for (int i = 0; i < multipart.getCount(); i++) {
@@ -69,8 +69,6 @@
                 }
                 //We have to do this because of a bug in JavaMail (ref id 4404733)
                 message.setContent(multipart);
-            } else {
-                //Give up... we won't attach the footer to this message
             }
         } catch (IOException ioe) {
             throw new MessagingException("Could not read message", ioe);
@@ -165,9 +163,17 @@
             addToText(part);
         } else if (part.isMimeType("text/html")) {
             addToHTML(part);
+        } else if (part.getContent() instanceof MimeMultipart) {
+            MimeMultipart multipart = (MimeMultipart)part.getContent();
+            int count = multipart.getCount();
+            for (int index = 0; index < count; index++) {
+                MimeBodyPart mimeBodyPart = 
+(MimeBodyPart)multipart.getBodyPart(index);
+                attachFooter(mimeBodyPart);
+            }
+            part.setContent(multipart);
         } else {
-            System.err.println(part.getContentType());
+            //Give up... we won't attach the footer to this message
+            //System.err.println(part.getContentType());
         }
-        //Give up... we won't attach the footer to this message
     }
 }

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

Reply via email to