home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / nntppost.al < prev    next >
Encoding:
Text File  |  2004-03-29  |  1.3 KB  |  66 lines

  1. # NOTE: Derived from blib\lib\Mail/Internet.pm.
  2. # Changes made here will be lost when autosplit is run again.
  3. # See AutoSplit.pm.
  4. package Mail::Internet;
  5.  
  6. #line 657 "blib\lib\Mail/Internet.pm (autosplit into blib\lib\auto\Mail\Internet\nntppost.al)"
  7. sub nntppost;
  8.  
  9. use Mail::Util qw(mailaddress);
  10. use Net::NNTP;
  11. use strict;
  12.  
  13.  sub nntppost
  14. {
  15.     my $mail = shift;
  16.     my %opt = @_;
  17.  
  18.     my $groups = $mail->get('Newsgroups') || "";
  19.     my @groups = split(/[\s,]+/,$groups);
  20.  
  21.     return ()
  22.     unless @groups;
  23.  
  24.     my $hdr = $mail->head->dup;
  25.  
  26.     _prephdr($hdr);
  27.  
  28.     # Remove these incase the NNTP host decides to mail as well as me
  29.     $hdr->delete(qw(To Cc Bcc)); 
  30.  
  31.     my $news;
  32.     my $noquit = 0;
  33.     my $host = $opt{Host};
  34.  
  35.     if(ref($host) && UNIVERSAL::isa($host,'Net::NNTP')) {
  36.     $news = $host;
  37.     $noquit = 1;
  38.     }
  39.     else {
  40.     my @opt = ();
  41.  
  42.     push(@opt, $opt{'Host'});
  43.  
  44.     push(@opt, 'Port', $opt{'Port'})
  45.         if exists $opt{'Port'};
  46.  
  47.     push(@opt, 'Debug', $opt{'Debug'})
  48.         if exists $opt{'Debug'};
  49.  
  50.     $news = new Net::NNTP(@opt)
  51.         or return ();
  52.     }
  53.  
  54.     $news->post(@{$hdr->header},"\n",@{$mail->body});
  55.  
  56.     my $code = $news->code;
  57.  
  58.     $news->quit
  59.     unless $noquit;
  60.  
  61.     return 240 == $code ? @groups : ();
  62. }
  63.  
  64. # end of Mail::Internet::nntppost
  65. 1;
  66.