Net::NNTP::Auth - a standard NNTP authentication method


  use Net::NNTP::Auth;
  my ($nntpuser, $nntppass) = Net::NNTP::Auth->nntpauth($server->server);

  use Net::NNTP;
  my $nntp = new Net::NNTP;
  $nntp->authinfo($nntpuser, $nntppass);


NNTP authentication is a standard feature of most news servers nowadays, though many news readers have yet to catch up. When writing your own news reader, though, you have to keep track of this data separately, unless you have a standardized place to store the information - like this module.

This module offers a few functions which parse the local ~/.nntpauth file and return the appropriate data. This file contains lines that look like this:

  news.server.invalid username password 
  news2.server2.invalid username2 password4

That's it. The functions are called by offering forth a SERVER, and the first user/password pair in the file is returned. These values can then be passed into Net::NNTP's nntpauth() function.


nntpauth ( SERVER )

Parses ~/.nntpauth for the given SERVER. Returns two items - the user name and the password. If one or both of these is not found, then the appropriate value is set to 'undef'.

nntpuser ( SERVER )
nntppass ( SERVER )

Invokes nntpauth(), and returns the appropriate item from the list - the user name for nntpuser(), or the password for nntppass().


Please note that this is an extremely small module. The only real purpose is to standardize on the ~/.nntpauth format that I've been using for a long time. It's convenient. Why not?


Written by Tim Skirvin <>


This code may be redistributed under the same terms as Perl itself.


Copyright 2000-2004 by Tim Skirvin <>. This code may be redistributed under the same terms as Perl itself.