"Fossies" - the Fresh Open Source Software Archive

Member "formmail_modules-3.14m1/lib/CGI/NMS/Mailer.pm" (11 Aug 2004, 2818 Bytes) of package /linux/www/old/formmail_modules-3.14m1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Mailer.pm" see the Fossies "Dox" file reference documentation.

    1 package CGI::NMS::Mailer;
    2 use strict;
    3 
    4 use POSIX qw(strftime);
    5 
    6 =head1 NAME
    7 
    8 CGI::NMS::Mailer - email sender base class
    9 
   10 =head1 SYNOPSYS
   11 
   12   use base qw(CGI::NMS::Mailer);
   13 
   14   ...
   15 
   16 =head1 DESCRIPTION
   17 
   18 This is a base class for classes implementing low-level email
   19 sending objects for use within CGI scripts.
   20 
   21 =head1 METHODS
   22 
   23 =over
   24 
   25 =item output_trace_headers ( TRACEINFO )
   26 
   27 Uses the print() virtual method to output email abuse tracing headers
   28 including whatever useful information can be gleaned from the CGI
   29 environment variables.
   30 
   31 The TRACEINFO parameter should be a short string giving the name and
   32 version of the CGI script.
   33 
   34 =cut
   35 
   36 sub output_trace_headers {
   37   my ($self, $traceinfo) = @_;
   38 
   39   $ENV{REMOTE_ADDR} =~ /^\[?([\d\.\:a-f]{7,100})\]?$/i or die
   40      "failed to get remote address from [$ENV{REMOTE_ADDR}], so can't send traceable email";
   41   $self->print("Received: from [$1]\n");
   42 
   43   my $me = ($ENV{SERVER_NAME} =~ /^([\w\-\.]{1,100})$/ ? $1 : 'unknown');
   44   $self->print("\tby $me ($traceinfo)\n");
   45 
   46   my $date = strftime '%a, %e %b %Y %H:%M:%S GMT', gmtime;
   47   $self->print("\twith HTTP; $date\n");
   48 
   49   if ($ENV{SCRIPT_NAME} =~ /^([\w\-\.\/]{1,100})$/) {
   50     $self->print("\t(script-name $1)\n");
   51   }
   52 
   53   if (defined $ENV{HTTP_HOST} and $ENV{HTTP_HOST} =~ /^([\w\-\.]{1,100})$/) {
   54     $self->print("\t(http-host $1)\n");
   55   }
   56 
   57   my $ff = $ENV{HTTP_X_FORWARDED_FOR};
   58   if (defined $ff) {
   59     $ff =~ /^\s*([\w\-\.\[\] ,]{1,200})\s*/ or die
   60       "malformed X-Forwarded-For [$ff], suspect attack, aborting";
   61 
   62     $self->print("\t(http-x-forwarded-for $1)\n");
   63   }
   64 
   65   my $ref = $ENV{HTTP_REFERER};
   66   if (defined $ref and $ref =~ /^([\w\-\.\/\:\;\%\@\#\~\=\+\?]{1,100})$/) {
   67     $self->print("\t(http-referer $1)\n");
   68   }
   69 }
   70 
   71 =back
   72 
   73 =head1 VIRTUAL METHODS
   74 
   75 Subclasses must implement the following methods:
   76 
   77 =over
   78 
   79 =item newmail ( TRACEINFO, SENDER, @RECIPIENTS )
   80 
   81 Starts a new email.  TRACEINFO is the script name and version, SENDER is
   82 the email address to use as the envelope sender and @RECIPIENTS is a list
   83 of recipients.  Dies on error.
   84 
   85 =item print ( @ARGS )
   86 
   87 Concatenates the arguments and appends them to the email.  Both the
   88 header and the body should be sent in this way, separated by a single
   89 blank line.  Dies on error.
   90 
   91 =item endmail ()
   92 
   93 Finishes the email, flushing buffers and sending it.  Dies on error.
   94 
   95 =back
   96 
   97 =head1 SEE ALSO
   98 
   99 L<CGI::NMS::Mailer::Sendmail>, L<CGI::NMS::Mailer::SMTP>,
  100 L<CGI::NMS::Script>
  101 
  102 =head1 MAINTAINERS
  103 
  104 The NMS project, E<lt>http://nms-cgi.sourceforge.net/E<gt>
  105 
  106 To request support or report bugs, please email
  107 E<lt>nms-cgi-support@lists.sourceforge.netE<gt>
  108 
  109 =head1 COPYRIGHT
  110 
  111 Copyright 2003 London Perl Mongers, All rights reserved
  112 
  113 =head1 LICENSE
  114 
  115 This module is free software; you are free to redistribute it
  116 and/or modify it under the same terms as Perl itself.
  117 
  118 =cut
  119 
  120 1;
  121