Index: C:/progettilavoro2/james-trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java =================================================================== --- C:/progettilavoro2/james-trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (revision 264794) +++ C:/progettilavoro2/james-trunk/src/java/org/apache/james/transport/mailets/RemoteDelivery.java (working copy) @@ -508,9 +508,23 @@ log("Error during the conversion to 7 bit.", e); } } + + /* + * Workaround for a javamail 1.3.2 bug: if + * a message is sent without encoding information + * and the 8bit allow property is set an exception + * is trown during the mail delivery. + */ + + try { + setEncodingIfMissing(message); + } catch (IOException e) { + log("Error while adding encoding information to the message", e); + } } else { // If the transport is not the one - // developed by Sun we are not sure of how it handles the 8 bit mime stuff, + // developed by Sun we are not sure of how it + // handles the 8 bit mime stuff, // so I convert the message to 7bit. try { convertTo7Bit(message); @@ -747,6 +761,29 @@ } /** + * Adds an encoding information to each text mime part. This is a workaround + * for a javamail 1.3.2 bug: if a message is sent without encoding + * information a null pointer exception is thrown during the message + * delivery. + * + * @param part + * @throws MessagingException + * @throws IOException + */ + private void setEncodingIfMissing(MimePart part) throws MessagingException, IOException { + if (part.isMimeType("text/*")) { + String enc = part.getEncoding(); + if (enc == null) part.setHeader("Content-Transfer-Encoding", "7bit"); + } else if (part.isMimeType("multipart/*")) { + MimeMultipart parts = (MimeMultipart) part.getContent(); + int count = parts.getCount(); + for (int i = 0; i < count; i++) { + setEncodingIfMissing((MimePart)parts.getBodyPart(i)); + } + } + } + + /** * Insert the method's description here. * Creation date: (2/25/00 1:14:18 AM) * @param mail org.apache.james.core.MailImpl