Email::Send::NNTP - Post Messages to a News Server


Email-Send documentation Contained in the Email-Send distribution.

Index


Code Index:

NAME

Top

Email::Send::NNTP - Post Messages to a News Server

SYNOPSIS

Top

  use Email::Send;

  my $mailer = Email::Send->new({mailer => 'NNTP'});

  $mailer->mailer_args([Host => 'nntp.example.com']);

  $mailer->send($message);

DESCRIPTION

Top

This is a mailer for Email::Send that will post a message to a news server. The message must be formatted properly for posting. Namely, it must contain a Newsgroups: header. At least the first invocation of send requires a news server arguments. After the first declaration the news server will be remembered until such time as you pass another one in.

SEE ALSO

Top

Email::Send, Net::NNTP, perl.

AUTHOR

Top

Current maintainer: Ricardo SIGNES, <rjbs@cpan.org>.

Original author: Casey West, <casey@geeknest.com>.

COPYRIGHT

Top


Email-Send documentation Contained in the Email-Send distribution.

package Email::Send::NNTP;
use strict;

use vars qw[$NNTP $VERSION];
use Net::NNTP;
use Return::Value;

$VERSION   = '2.198';

sub is_available {
    return   eval { require Net::NNTP }
           ? success
           : failure $@;
}

sub send {
    my ($class, $message, @args) = @_;
    eval { require Net::NNTP };
    if ( @_ > 1 ) {
        $NNTP->quit if $NNTP;
        $NNTP = Net::NNTP->new(@args);
        return failure unless $NNTP;
    }
    return failure unless $NNTP->post( $message->as_string );
    return success;
}

sub DESTROY {
    $NNTP->quit if $NNTP;
}

1;

__END__