1 |
#!/usr/bin/perl |
2 |
|
3 |
use strict; |
4 |
use warnings; |
5 |
|
6 |
use Data::Dumper; |
7 |
use Net::NNTP; |
8 |
use News::Article; |
9 |
|
10 |
|
11 |
my $connInfo = { |
12 |
host => 'news.netfrag.org', |
13 |
user => 'collector', |
14 |
pass => 'col5%', |
15 |
}; |
16 |
|
17 |
# connect to news-server |
18 |
my $nntp = Net::NNTP->new( $connInfo->{host} ); |
19 |
|
20 |
# authenticate with nntp-server |
21 |
$nntp->authinfo( $connInfo->{user}, $connInfo->{pass} ); |
22 |
|
23 |
|
24 |
# read smtp-message from STDIN |
25 |
my @msg_smtp = <STDIN>; |
26 |
|
27 |
# build news-message |
28 |
my $msg_nntp = News::Article->new( \@msg_smtp ); |
29 |
|
30 |
$msg_nntp->set_headers( |
31 |
'Newsgroups', 'alt.test', |
32 |
'From', 'test@netfrag.org', |
33 |
); |
34 |
|
35 |
# tracing |
36 |
print Dumper($msg_nntp); |
37 |
#exit; |
38 |
|
39 |
# post message to news-server |
40 |
$msg_nntp->post( $nntp ); |
41 |
|
42 |
# disconnect from news-server |
43 |
$nntp->quit; |
44 |
|
45 |
1; |
46 |
|