to = 'mailinglist@akbkhome.com'; $this->connect(); $this->sendGroup("digitalmars.D.announce", "D.announce"); $this->sendGroup("digitalmars.D", "D.general"); $this->sendGroup("digitalmars.D.learn", "D.learn"); $this->sendGroup("DMDScript", "DMDScript"); } function connect() { $this->nntp = new Net_NNTP_Client; $ret = $this->nntp->connect('news.digitalmars.com'); if( PEAR::isError($ret)) { print_r($ret); exit; } } function sendGroup($newsgroup, $newsgroupSubj) { $last = 0; if (file_exists('/etc/NNTPtoMail/'.$newsgroup.'.last')) { $last = (int) file_get_contents('/etc/NNTPtoMail/'.$newsgroup.'.last'); } $data = $this->nntp->selectGroup($newsgroup); if (!$last) { $last = $data['last'] - 10; } $msgs = $this->nntp->getOverview( $last + 1, $data['last']); foreach($msgs as $msg) { // print subjects //echo "SEND:" . $msg['number'] . "\n"; $body = implode("\n", $this->nntp->getBodyRaw($msg['number'])); $mail = Mail::factory('smtp',array( 'host'=>'127.0.0.1' )); $headers = array(); foreach($msg as $k=>$v) { if (in_array(strtolower($k),array('subject','from', 'date','message-id','references'))) { $headers[$k] = $v; } else { $headers['X-NNTP-'.$k] = $v; } } $headers['Reply-to'] = $headers['from'] ; // $headers['from'] = $headers['from'] ; //'alan@akbkhome.com'; $headers['Subject'] = '['.$newsgroupSubj.'] '.$headers['Subject']; $headers['To']= $this->to; // would be nice to add reply-to header to enable reply to.. $ret = $mail->send($headers['To'], $headers, $body); //var_dump($ret); //exit; } file_put_contents('/etc/NNTPtoMail/'.$newsgroup.'.last', $data['last']); } } // print the last 10 messages new NNTPtoMail();