NAME

  Mail::SpamCannibal::ParseMessage - parse mail headers


SYNOPSIS

  use Mail::SpamCannibal::ParseMessage qw(
        limitread
        dispose_of
        headers
        rfheaders
        skiphead 
        get_MTAs
        firstremote
        array2string
        string2array
  );
  $chars = limitread(*H,\@lines,$limit);
  $rv = dispose_of(*H,$limit);
  $hdrs = headers(\@lines,\@headers);
  $hdrs = rfheaders(\@lines,\@headers);
  $lines = skiphead(\@lines);
  $mtas = get_MTAs(\@headers,\@mtas);
  $from = firstremote(\@MTAs,\@myhosts,$noprivate);
  $string = array2string(\@array,$begin,$end);
  $count = string2array($string,\@array);


DESCRIPTION

Mail::SpamCannibal::ParseMessage provides utilities to parse mail headers and email messages containing mail headers as their message content to find the origination Mail Transfer Agent.

  use Mail::SpamCannibal::ParseMessage qw(
        limitread
        dispose_of
        headers   
        skiphead  
        get_MTAs  
        firstremote
        array2string
        string2array
  );
  # example of reading mail message from STDIN
  # read up to 10000 characters
  my @lines;
  exit unless limitread(*STDIN,\@lines,10000);
  # release the daemon feeding this script
  dispose_of(*STDIN);
  # optional, if message content is headers
  # skip the real headers on this message
  exit unless skiphead(\@lines);
  # linearize headers, convert multi-line headers
  # to single line, removing extra white space
  my @headers;
  exit unless headers(\@lines,\@headers);
  # get list of MTA's from headers  
  my @mtas;
  exit unless get_MTAs(\@headers,\@mtas);
  # extract the first remote MTA from the 
  # resulting MTA object
  my @myhosts = qw(
        mail1.mydomain.com
        mail2.mydomain.com
  };
  my $remoteIP = firstremote(\@mtas,\@myhosts);


SUBROUTINE DESCRIPTIONS


DEPENDENCIES

  NetAddr::IP::Lite version 0.02


EXPORT

        none


EXPORT_OK

        limitread
        dispose_of
        headers
        rfheaders
        skiphead
        get_MTAs
        firstremote
        array2string
        string2array
        trimmsg


AUTHOR

Michael Robinton <michael@bizsystems.com>


COPYRIGHT

Copyright 2003 - 2007, Michael Robinton <michael@bizsystems.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


SEE ALSO

perl(1)