Mail::ListDetector::Detector::Listserv - Listserv message detector


Mail-ListDetector documentation Contained in the Mail-ListDetector distribution.

Index


Code Index:

NAME

Top

Mail::ListDetector::Detector::Listserv - Listserv message detector

SYNOPSIS

Top

  use Mail::ListDetector::Detector::Listserv;

DESCRIPTION

Top

An implementation of a mailing list detector, for LISTSERV(R) mailing lists, LISTSERV(R) is commercial email list management software, see <http://www.lsoft.com/> for details.

There is very little to go on to detect a LISTSERV(R) message, this detector needs to be called close to last.

METHODS

Top

new()

Inherited from Mail::ListDetector::Detector::Base.

match()

Accepts a Mail::Internet object and returns either a Mail::ListDetector::List object if it is a post to a Listserv mailing list, or undef.

BUGS

Top

No known bugs.

AUTHOR

Top

Matthew Walker - matthew@walker.wattle.id.au, Michael Stevens - michael@etla.org, Peter Oliver - p.d.oliver@mavit.freeserve.co.uk. Tatsuhiko Miyagawa <miyagawa@bulknews.net>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Mail-ListDetector documentation Contained in the Mail-ListDetector distribution.

package Mail::ListDetector::Detector::Listserv;

use strict;
use warnings;

use vars qw($VERSION);
$VERSION = '0.01';

use base qw(Mail::ListDetector::Detector::Base);
use Mail::ListDetector::List;

sub DEBUG { 0 }

sub match {
  my $self = shift;
  my $message = shift;
  print "Got message $message\n" if DEBUG;
  carp ("Mail::ListDetector::Detector::Listserv - no message supplied") unless defined($message);
  use Email::Abstract;

  my ($posting_address, $list_name, $list_software);
  my @received = Email::Abstract->get_header($message, 'Received');
  foreach my $received (@received) {
#	$received =~ s/\n/ /;
	if($received =~ m/\(LISTSERV-TCP\/IP\s+release\s+([^\s]+)\)/s) {
      $list_software = "LISTSERV-TCP/IP release $1";
      my $sender = Email::Abstract->get_header($message, 'Sender');
      if($sender =~ m/^(.*) <(.+)>$/) {
		$list_name = $1;
        $posting_address = $2;
      }
      last;
    }
  }

  unless (defined $list_software) { return undef; }

  my $list = new Mail::ListDetector::List;
  if(defined $list_name) {
    $list->listname($list_name);
  } else {
    $list->listname($posting_address);
  }
  $list->listsoftware($list_software);
  $list->posting_address($posting_address);

  return $list;
}

1;

__END__