--- old/NewsgroupExporter.java	2008-12-03 16:30:39.000000000 +0300
+++ new/NewsgroupExporter.java	2008-12-03 16:33:08.000000000 +0300
@@ -9,8 +9,8 @@
 package com.jivesoftware.community.gateway;
 
 import com.jivesoftware.base.*;
+import com.jivesoftware.base.wiki.WikiContentHelper;
 import com.jivesoftware.community.*;
-import com.jivesoftware.community.renderer.impl.v2.JAXPUtils;
 import com.jivesoftware.community.impl.DbForumMessage;
 import com.jivesoftware.community.lifecycle.JiveApplication;
 import com.jivesoftware.util.ClassUtilsStatic;
@@ -24,8 +24,9 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Properties;
+import java.util.StringTokenizer;
 
-import org.w3c.dom.*;
+import org.w3c.dom.Document;
 
 /**
  * A gateway for the export of messages to a newsgroup.
@@ -107,7 +108,7 @@
         }
         catch (MessagingException e) {
             Log.error("Error exporting message via NNTP gateway in community " +
-                    community.getName() + ", Reason: " + e.getMessage());
+                    community.getName() + ", messageID: " + forumMessage.getID() + ", Reason: " + e.getMessage());
 
             throw new GatewayException(e);
         }
@@ -183,7 +184,7 @@
         }
         catch (MessagingException e) {
             Log.error("Error exporting message via NNTP gateway in community " +
-                    community.getName() + ", Reason: " + e.getMessage());
+                    community.getName() + ", messageID: " + forumMessages[x].getID() + ", Reason: " + e.getMessage());
 
             throw new GatewayException(e);
         }
@@ -221,7 +222,9 @@
         message.setSubject(subject, getMimeCharacterEncoding());
 
         // set the date on exported messages to be the creation date of the message
-        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
+//        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",
+//                java.util.Locale.US);
+        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",
                 java.util.Locale.US);
         format.setTimeZone(JiveGlobals.getTimeZone());
         message.setHeader("Date", format.format(forumMessage.getCreationDate()));
@@ -722,6 +725,7 @@
                 }
                 else {
                     email = user.getEmail();
+                    if (invalidEmail(email)) email = getDefaultFromAddress();
                 }
                 fromAddress = new InternetAddress(email, name, getMimeCharacterEncoding());
             }
@@ -761,6 +765,13 @@
         return fromAddress;
     }
 
+    private boolean invalidEmail(String email) {
+        if (!email.contains("@")) return true;
+        if (!email.contains(".")) return true;
+        if (!email.contains(" ")) return true;
+        return false;
+    }
+
     /**
      * Utility method to add ForumMessage content and attachments
      * to a MimeMessage.
@@ -772,7 +783,10 @@
         try {
             // The body is the message + the footer.
             org.w3c.dom.Document domBody = forumMessage.getBody();
-            StringBuffer body = new StringBuffer(JAXPUtils.toXmlString(domBody));
+            //StringBuffer body = new StringBuffer(JAXPUtils.toXmlString(domBody));
+
+            String plain_text = wrapLongLines(WikiContentHelper.contentBodyToWikiText(domBody), 300);
+            StringBuffer body = new StringBuffer(plain_text);
 
             String footer = settings.getExportProperty("footer");
             if (footer == null) {
@@ -808,6 +822,7 @@
             }
             else {
                 message.setText(body.toString(), getMimeCharacterEncoding());
+                //message.setContent(body.toString(), "text/html");
             }
         }
         catch (MessagingException e) {
@@ -854,10 +869,33 @@
     }
 
     public ForumManager getForumManager() {
+        forumManager = JiveApplication.getContext().getForumManager();
         return forumManager;
     }
 
     public void setForumManager(ForumManager forumManager) {
         this.forumManager = forumManager;
     }
+    
+    private static String wrapLongLines(String body, int limit) {
+        final String separator = System.getProperty("line.separator");
+        final StringBuilder result = new StringBuilder(body.length());
+        final StringTokenizer tokenizer = new StringTokenizer(body, separator, true);
+        while(tokenizer.hasMoreTokens()) {
+            result.append(wrapString(tokenizer.nextToken(), limit, separator));
+        }
+        return result.toString();
+    }
+
+    private static String wrapString(String body, int limit, String separator) {
+        if (body.length() <= limit) {
+            return body;
+        }
+        StringBuilder builder = new StringBuilder(body);
+        for (int insertionIndex = limit; insertionIndex < builder.length(); insertionIndex += (limit + separator.length())) {
+            builder.insert(insertionIndex, separator);
+        }
+        return builder.toString();  //To change body of created methods use File | Settings | File Templates.
+    }
+
 }
\ No newline at end of file
