lib/TWiki/Configure/Checkers/MailProgram.pm
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 #
     2 # TWiki Enterprise Collaboration Platform, http://TWiki.org/
     3 #
     4 # Copyright (C) 2000-2006 TWiki Contributors.
     5 #
     6 # This program is free software; you can redistribute it and/or
     7 # modify it under the terms of the GNU General Public License
     8 # as published by the Free Software Foundation; either version 2
     9 # of the License, or (at your option) any later version. For
    10 # more details read LICENSE in the root of this distribution.
    11 #
    12 # This program is distributed in the hope that it will be useful,
    13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    15 #
    16 # As per the GPL, removal of this notice is prohibited.
    17 package TWiki::Configure::Checkers::MailProgram;
    18 
    19 use strict;
    20 
    21 use TWiki::Configure::Checker;
    22 
    23 use base 'TWiki::Configure::Checker';
    24 
    25 sub check {
    26     my $this = shift;
    27 
    28     return '' if( !$Twiki::cfg{EnableEmail} );
    29 
    30     eval "use Net::SMTP";
    31     my $n;
    32     my $useprog = 0;
    33     if ($@) {
    34         $n = "Net::SMTP is <b>not</b> installed in this environment. ";
    35         $useprog = 1;
    36     } elsif( !$TWiki::cfg{SMTP}{MAILHOST} ) {
    37         $n = $this->WARN('Net::SMTP is installed in this environment, but {SMTP}{MAILHOST} is not defined, so the {MailProgram} <b>will</b> be used..');
    38         $useprog = 1;
    39     } else {
    40         $n = $this->NOTE('<em>Net::SMTP is installed in this environment, so this setting will <b>not</b> be used.</em>');
    41         $useprog = 0;
    42     }
    43     if ($useprog) {
    44         my $val = $TWiki::cfg{MailProgram} || '';
    45         $val =~ s/\s.*$//g;
    46         if( ! ( -x $val ) ) {
    47             $n .= $this->WARN("<tt>$val</tt> was not found. Check the path.");
    48         }
    49     }
    50     return $n;
    51 }
    52 
    53 1;