Post a message on a newsserver using NNTP protocol (this howto is deprecated)Tag(s): DEPRECATED
This snippet uses an undocumented Sun package [JDK1.1]
import sun.net.nntp.*;
import java.io.*;
public class NntpPost {
public static void main(String[] args) throws IOException {
/*
** pass your news server as parameter
** eg. java NttpPost news.server.com
*/
NntpClient c = new NntpClient(args[0]);
NewsgroupInfo ni = c.getGroup("alt.test");
PrintStream p = c.startPost();
System.out.println("Starting post at " + args[0] + "...");
p.println("From: epresley@jailhouse.rock (Elvis Presley)");
p.println("Newsgroups: alt.test");
p.println("Subject: I'm alive");
p.println("");
p.println("Hi");
p.println("Don't be cruel, please help me");
p.println(" ");
p.println("Thanks in advance");
if (c.finishPost())
System.out.println("Ending post... success");
else
System.out.println("Ending post... failed");
c.closeServer();
}
}Here some java code to illustrate NTTP protocol without using the undocumented classes, Communicating with an NNTP server.
Sun's JavaMail APi can be used to interact with a NTTP server, check out the Knife Plugin.
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com