Posting with Net::NNTP

M

Mike

Hey guys,

I really appeciate all the help you've given me so far regarding
Net::NNTP.

I've been able to successfully view posts in specific newsgroups now,
using a "public" news server. However, I'm trying to post, and
although the program runs without errors, nothing's posting. Can
someone glance this script over and let me know if it's the program or
the server?


#!/usr/bin/perl
use Net::NNTP;
use strict;

my $server = "news.so-net.com.hk";
# one of a few that I tried; also tried my ISP
my $group = "alt.test";

my $nntp = Net::NNTP->new($server, Debug => 0) or die "Can't connect
to server: $!\n";

my @message = (
"Subject: This is a Test",
"From: Mike <csdude\@spampolice.com>",
"Newsgroups: $group",
"\nThis is an Net::NNTP test.\n"
);

$nntp -> post(@message);
$nntp->quit;

print "Content-type: text/html\n\n";
print "Success\n\n";
exit;


TIA,

Mike
 
J

John W. Krahn

Mike said:
I really appeciate all the help you've given me so far regarding
Net::NNTP.

I've been able to successfully view posts in specific newsgroups now,
using a "public" news server. However, I'm trying to post, and
although the program runs without errors, nothing's posting. Can
someone glance this script over and let me know if it's the program or
the server?

#!/usr/bin/perl
use Net::NNTP;
use strict;

my $server = "news.so-net.com.hk";
# one of a few that I tried; also tried my ISP
my $group = "alt.test";

my $nntp = Net::NNTP->new($server, Debug => 0) or die "Can't connect
to server: $!\n";

my @message = (
"Subject: This is a Test",
"From: Mike <csdude\@spampolice.com>",
"Newsgroups: $group",
"\nThis is an Net::NNTP test.\n"
);

$nntp -> post(@message);
$nntp->quit;

print "Content-type: text/html\n\n";
print "Success\n\n";
exit;


According to RFC977:

3.10. The POST command

3.10.1. POST

POST

If posting is allowed, response code 340 is returned to indicate that
the article to be posted should be sent. Response code 440 indicates
that posting is prohibited for some installation-dependent reason.

If posting is permitted, the article should be presented in the
format specified by RFC850, and should include all required header
lines. After the article's header and body have been completely sent
by the client to the server, a further response code will be returned
to indicate success or failure of the posting attempt.


http://www.rfc-editor.org/rfc/rfc977.txt


RFC850 has been obsoleted by RFC1036:

http://www.rfc-editor.org/rfc/rfc1036.txt



John
 
M

Mike

[...]
missing newline


Thanks, John and Tina. The \n was exactly it. Geez, you'd have thought
I would have caught that myself! I think my brain's starting to fry...

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top