PHPackages                             dariusiii/net\_nntp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. dariusiii/net\_nntp

ActiveLibrary[HTTP &amp; Networking](/categories/http)

dariusiii/net\_nntp
===================

Package for communication with NNTP/Usenet servers.

4.1.3(2mo ago)0114W3CPHPPHP &gt;=8.5

Since Nov 3Pushed 2mo agoCompare

[ Source](https://github.com/DariusIII/Net_NNTP)[ Packagist](https://packagist.org/packages/dariusiii/net_nntp)[ Docs](https://github.com/DariusIII/Net_NNTP)[ RSS](/packages/dariusiii-net-nntp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Net\_NNTP
=========

[](#net_nntp)

A PHP library for communicating with NNTP (Usenet) servers.

[![PHP Version](https://camo.githubusercontent.com/d34bb3815837b58c993746acbcf32acec642413e9ce88370a4379cd823168939/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e352d3838393242462e737667)](https://php.net)[![PHPStan Level](https://camo.githubusercontent.com/6e33b77b51a771e6655e2b9229dca1682109fdbaae399ff6b2d6d7a4d5e35db7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068707374616e2d6c6576656c253230382d627269676874677265656e2e737667)](https://phpstan.org)[![License](https://camo.githubusercontent.com/edc98bedcb8eb44b6bc6f24492a376c532f07a7a8622857a901d20fe6fc0a63b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d5733432d626c75652e737667)](LICENSE.md)

Description
-----------

[](#description)

Net\_NNTP provides a full-featured client for the NNTP protocol ([RFC 3977](https://tools.ietf.org/html/rfc3977)), allowing PHP applications to connect to Usenet/NNTP servers to read, post, and manage newsgroup articles.

The library is split into two layers:

- **`DariusIII\NetNntp\Protocol\Client`** — low-level protocol implementation that maps directly to NNTP commands (`GROUP`, `ARTICLE`, `HEAD`, `BODY`, `POST`, `XOVER`, etc.)
- **`DariusIII\NetNntp\Client`** — high-level API that provides a convenient interface for common operations (selecting groups, fetching articles, posting, overview, etc.)

### Features

[](#features)

- Full NNTP protocol support (RFC 3977 + common extensions)
- SSL/TLS encrypted connections
- STARTTLS negotiation
- Authentication (AUTHINFO USER/PASS)
- Article retrieval (full, header-only, body-only)
- Article posting via raw data or mail-style parameters
- Group listing with wildmat filtering
- Overview (XOVER) and header field (XHDR) support
- PSR-3 compatible logging — plug in any logger (Monolog, etc.)
- Strongly typed with `declare(strict_types=1)` throughout
- Int-backed `ResponseCode` enum with all 53 NNTP response codes
- PHPStan level 8 verified

Requirements
------------

[](#requirements)

- PHP 8.5 or later
- `psr/log` ^3.0
- `vlucas/phpdotenv` ^5.6 (for demo configuration)

Installation
------------

[](#installation)

```
composer require dariusiii/net_nntp
```

Quick Start
-----------

[](#quick-start)

```
use DariusIII\NetNntp\Client;
use DariusIII\NetNntp\Error;

$client = new Client();

// Connect
$result = $client->connect('news.example.com', 'ssl', 563);

// Authenticate (if required)
$client->authenticate('username', 'password');

// Select a group
$summary = $client->selectGroup('alt.test');
echo "Group: {$summary['group']}, Articles: {$summary['count']}\n";

// Fetch an article header
$header = $client->getHeader(null, implode: true);

// Fetch article body
$body = $client->getBody();

// Get overview for a range
$overview = $client->getOverview("{$summary['first']}-{$summary['last']}");

// Post an article
$client->post("Newsgroups: alt.test\r\nSubject: Test\r\nFrom: user@example.com\r\n\r\nHello, Usenet!");

// Disconnect
$client->disconnect();
```

Error Handling
--------------

[](#error-handling)

Methods return an `Error` object on failure rather than throwing exceptions. Check with `Error::isError()`:

```
$result = $client->selectGroup('nonexistent.group');
if (Error::isError($result)) {
    echo "Error: " . $result->getMessage() . "\n";
}
```

Logging
-------

[](#logging)

The library accepts any PSR-3 compatible logger:

```
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('nntp');
$logger->pushHandler(new StreamHandler('nntp.log'));

$client = new Client();
$client->setLogger($logger);
```

Response Codes
--------------

[](#response-codes)

All NNTP response codes are available as a strongly-typed int-backed enum:

```
use DariusIII\NetNntp\Protocol\ResponseCode;

$code = ResponseCode::from(200);           // ResponseCode::ReadyPostingAllowed
echo $code->value;                         // 200
echo $code->description();                 // "Server ready, posting allowed"
echo ResponseCode::tryFrom(999);           // null (invalid code)
```

Development
-----------

[](#development)

```
# Install dependencies
composer install

# Run static analysis (PHPStan level 8)
composer analyse

# Run tests
composer test

# Run both
composer check
```

Project Structure
-----------------

[](#project-structure)

```
src/
├── Client.php                  # High-level NNTP client API
├── Error.php                   # Error class
└── Protocol/
    ├── Client.php              # Low-level NNTP protocol implementation
    └── ResponseCode.php        # Int-backed enum of all NNTP response codes
tests/
├── Unit/                       # Unit tests
│   ├── AutoloadTest.php
│   ├── ClientTest.php
│   ├── ConfigTest.php
│   ├── ErrorTest.php
│   ├── ProtocolClientTest.php
│   └── ResponsecodeTest.php
└── Integration/                # Live server integration tests
    └── ServerConnectionTest.php
docs/
└── examples/                   # Demo application and phpdoc examples

```

⚠️ Breaking Changes in v4.x
---------------------------

[](#️-breaking-changes-in-v4x)

**If you are upgrading from v3.x or earlier, please read carefully.**

### v4.0.0

[](#v400)

This was a complete modernization release. Key breaking changes:

- **Namespace change**: All classes moved from PEAR-style names (`Net_NNTP_Client`) to PSR-4 namespaces (`Net\NNTP\Client`)
- **PEAR removed entirely**: No more PEAR dependencies, `PEAR::isError()`, or `PEAR_Error`. Use `Error::isError()` instead.
- **PSR-3 logging only**: The old `setDebug()` / PEAR Log integration was removed. Use `setLogger()` with any PSR-3 logger.
- **PHP 8.5+ required**: Uses enums, `match` expressions, `readonly` properties, `str_starts_with()`, `declare(strict_types=1)`, and other modern PHP features.
- **Response code enum**: `NET_NNTP_PROTOCOL_RESPONSECODE_*` global constants were replaced by a backwards-compatible shim delegating to the `ResponseCode` enum.

### v4.1.0

[](#v410)

This release completes the cleanup by removing all backward compatibility:

- **Namespace renamed again**: `Net\NNTP` → `DariusIII\NetNntp`

    - `Net\NNTP\Client` → `DariusIII\NetNntp\Client`
    - `Net\NNTP\Error` → `DariusIII\NetNntp\Error`
    - `Net\NNTP\Protocol\Client` → `DariusIII\NetNntp\Protocol\Client`
    - `Net\NNTP\Protocol\ResponseCode` → `DariusIII\NetNntp\Protocol\ResponseCode`
- **Legacy constants removed**: `NET_NNTP_PROTOCOL_RESPONSECODE_*` global constants no longer exist. Use the `ResponseCode` enum.
- **Deprecated methods removed** — these methods no longer exist:

    Removed methodReplacement`quit()``disconnect()``isConnected()`*(internal only)*`getArticleRaw()``getArticle()``getHeaderRaw()``getHeader()``getBodyRaw()``getBody()``getNewNews()``getNewArticles()``getReferencesOverview()``getReferences()`
- **Method signatures tightened**:

    - `getArticle()`, `getHeader()`, `getBody()`: `$implode` parameter is now `bool` (was `mixed` for v1.1 class-name compat)
    - `post()`: parameter is now `string|array` (was `mixed`; use `mail()` for multi-arg posting)
    - `getNewGroups()`, `getNewArticles()`: `$time` parameter is now `int|string` (was `mixed`)
    - `connect()`: no longer accepts port as the second argument

License
-------

[](#license)

[W3C Software Notice and License](LICENSE.md)

Credits
-------

[](#credits)

Originally created by [Heino H. Gehlsen](mailto:heino@gehlsen.dk). Modernized and maintained by [DariusIII](https://github.com/DariusIII).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance85

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Recently: every ~0 days

Total

12

Last Release

77d ago

Major Versions

2.1.0 → 3.0.12026-02-02

3.0.2 → 4.0.0.12026-02-24

PHP version history (2 changes)2.0PHP &gt;=8.2

2.1.0PHP &gt;=8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ab1ab6b00f6fd0010e38a3ba0ae92a716be659f72b6febbb6a24bb6d8a599ac?d=identicon)[DariusIII](/maintainers/DariusIII)

---

Top Contributors

[![heino](https://avatars.githubusercontent.com/u/551141?v=4)](https://github.com/heino "heino (163 commits)")[![DariusIII](https://avatars.githubusercontent.com/u/3399658?v=4)](https://github.com/DariusIII "DariusIII (29 commits)")[![tvvcox](https://avatars.githubusercontent.com/u/743820?v=4)](https://github.com/tvvcox "tvvcox (8 commits)")[![CicerBro](https://avatars.githubusercontent.com/u/177757655?v=4)](https://github.com/CicerBro "CicerBro (4 commits)")[![till](https://avatars.githubusercontent.com/u/27003?v=4)](https://github.com/till "till (4 commits)")[![stigsb](https://avatars.githubusercontent.com/u/169939?v=4)](https://github.com/stigsb "stigsb (3 commits)")[![CloCkWeRX](https://avatars.githubusercontent.com/u/365751?v=4)](https://github.com/CloCkWeRX "CloCkWeRX (2 commits)")[![zrtq](https://avatars.githubusercontent.com/u/20600767?v=4)](https://github.com/zrtq "zrtq (1 commits)")[![mj](https://avatars.githubusercontent.com/u/5277?v=4)](https://github.com/mj "mj (1 commits)")[![roojs](https://avatars.githubusercontent.com/u/415282?v=4)](https://github.com/roojs "roojs (1 commits)")[![sebastianbergmann](https://avatars.githubusercontent.com/u/25218?v=4)](https://github.com/sebastianbergmann "sebastianbergmann (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dariusiii-net-nntp/health.svg)

```
[![Health](https://phpackages.com/badges/dariusiii-net-nntp/health.svg)](https://phpackages.com/packages/dariusiii-net-nntp)
```

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k822.4M6.8k](/packages/symfony-http-kernel)[zircote/swagger-php

Generate interactive documentation for your RESTful API using PHP attributes (preferred) or PHPDoc annotations

5.3k132.9M468](/packages/zircote-swagger-php)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
