aboutsummaryrefslogtreecommitdiffstats
path: root/examples/drhyde-news2mail-and-mail2news/mail2news
diff options
context:
space:
mode:
Diffstat (limited to 'examples/drhyde-news2mail-and-mail2news/mail2news')
-rw-r--r--examples/drhyde-news2mail-and-mail2news/mail2news58
1 files changed, 0 insertions, 58 deletions
diff --git a/examples/drhyde-news2mail-and-mail2news/mail2news b/examples/drhyde-news2mail-and-mail2news/mail2news
deleted file mode 100644
index 1f026a0..0000000
--- a/examples/drhyde-news2mail-and-mail2news/mail2news
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/local/bin/perl
-
-use warnings;
-use strict;
-
-use Data::Dumper;
-use Net::NNTP;
-use News::Article;
-
-use constant DEBUG => 0;
-
-select(STDERR); $| = 1; select(STDOUT);
-
-die("mail2news hasn't been configured.\n") unless(-r '/etc/mail2newsrc');
-
-my $subs = { do '/etc/mail2newsrc' };
-
-my $group = shift;
-die("mail2news must be told what group to post to\n") unless($group);
-
-my $article = News::Article->new();
-$article->read(\*STDIN);
-$article->set_headers(Newsgroups => $group);
-$article->drop_headers(qw(date to received));
-$article->add_date();
-
-my $posted_ok = 0;
-foreach my $server (grep { $subs->{$_}->{$group} } keys %{$subs}) {
- my($auth, $host) = split('@', $server);
- ($auth, $host) = (':', $auth) if(!$host);
- my($user, $pass) = split(':', $auth);
- ($host, my $port) = split(':', $host);
- $port ||= 119;
-
- my $client = Net::NNTP->new($host, Port => $port);
- $client->authinfo($user => $pass) if($user);
-
- unless($client->postok()) {
- print STDERR "mail2news configured to post to $group via\n".
- "$server, but it didn't say we can post. Bother and damnation!\n";
- next;
- }
-
- eval { $article->post($client); };
- die("Error in posting to $server: $@\n") if($@);
- $posted_ok++;
-}
-
-if(!$posted_ok) {
- die "mail2news couldn't post to $group on any configured server.\n\n".
- "Your message read:\n\n".
- join("\n\n",
- join("\n", $article->headers()),
- join("\n", $article->body())
- )."\n\n".
- "And the environment was:\n\n".
- join("\n", map { join(":\t", $_, $ENV{$_}) } sort keys %ENV);
-}