-1

I'm trying to use PHP's imap_open function to connect to an NNTP server but have so far been entirely unsuccessful. (PHP documentation states that this is possible, despite IMAP access being the primary purpose of the function.) After trying fruitlessly to troubleshoot a few free newsreaders for PHP, I've boiled the code down to its very simplest element:

<?php
$nntp = imap_open("{news.mozilla.org:119/nntp}", "", "");
?>

However, you can see what happens when I try to run that on two completely different servers, configured by different organizations:

http://tiszenkel.com/channelone/nntn/nntp.php

http://video.channelone.com/newsreader/nntp.php

Is there some server setting I'm missing in both cases? (I'm not the administrator for either server, but I can make requests of the admin for one of them.)

boulevardofdef
  • 139
  • 3
  • 5
  • Well... I can only confirm it doesn't work here either (and I've checked with `nc news.mozilla.org 119` whether the service was available, and it is... – Wrikken Jun 19 '12 at 19:16
  • Hm, `imap_open("{216.196.97.169:119/nntp}","","",OP_HALFOPEN)` works... or at least doesn't fail miserably. – Wrikken Jun 19 '12 at 19:20
  • Are you certain that both servers have the IMAP extension available? –  Jun 19 '12 at 19:41

2 Answers2

2
$ref = '{news.mozilla.org:119/nntp}';
$imap = imap_open($ref,"","",OP_HALFOPEN);
var_dump(imap_list($imap,$ref,'*announce*'));

array(4) {
  [0]=>
  string(57) "{news.mozilla.org:119/nntp}mozilla.announce.compatibility"
  [1]=>
  string(59) "{news.mozilla.org:119/nntp}netscape.public.mozilla.announce"
  [2]=>
  string(43) "{news.mozilla.org:119/nntp}mozilla.announce"
  [3]=>
  string(52) "{news.mozilla.org:119/nntp}mozilla.dev.l10n.announce"
}
Wrikken
  • 69,272
  • 8
  • 97
  • 136
1

It looks as if you may need OP_ANONYMOUS as the fourth parameter of imap_open.

See the info & examples in this link:

PHP Cookbook entry on imap_open

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
Rob J
  • 11
  • 2
  • Those examples, which include OP_ANONYMOUS, didn't work, either -- but this is actually good, because it tells me that I've probably got an issue on the server side. I'll check to see what the server admin can do for me. – boulevardofdef Jun 19 '12 at 21:13