Search code examples
phpnntp

PHP and NNTP problems using imap_open


I am having a bit of trouble with NNTP and PHP (following the directions in the PHP manual, I threw in this quick test:

<?php
$server = "{news.newsserver.com/nntp:119}";
if ($nntp = imap_open($server,"myuser","mypass", OP_HALFOPEN)) {
    echo "Connected...\n";
    $list = imap_list($nntp, "{news.newsserver.com}", "*");
    if (is_array($list)) {
        foreach ($list as $val) {
            echo imap_utf7_decode($val) . "\n";
        }
    } else {
        echo "No groups found...\n";
    }
} else {
    echo "Unable to connect...\n";
}

When I run this script I get:

Connected... 
No groups found...
>

Any suggestions would be most appreciated. I am connecting to a valid server with a valid username and password. I am also aware of the Net_NNTP PEAR library, but I am at this point not interested in using that rather I just want to use whats 'build_in'ish to php.


Solution

  • Have you tried changing

    $list = imap_list($nntp, "{news.newsserver.com}", "*");
    

    To

    $list = imap_list($nntp, $server, "*");
    

    This worked when connecting to my newsserver.