Skip to content
Permalink
Browse files

Item10522: Add S/MIME support

Item10521: Fix errors in SSL support

Perltidy'd everything.

Note that the SSL commits has an impact on the automatic selection of
mail method - sendmail or Net::SMTP.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@12111 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
GeorgeClark GeorgeClark
GeorgeClark authored and GeorgeClark committed Jul 2, 2011
1 parent 32dd18f commit 0d4823be386c801ba5ae1eb5dd075dd25c657713
@@ -1182,10 +1182,11 @@ $Foswiki::cfg{Cache}{Servers} = '127.0.0.1:11211';
# <p>Settings controlling if and how Foswiki sends email, and the proxies used
# to access external web pages.</p>

#---++ General Email Configuration
#---++ Email General
# <p>Settings controlling if and how Foswiki sends email</p>
# **BOOLEAN**
# Enable email globally.
# Enable email globally. Un-check this option to disable all outgoing
# email from Foswiki
$Foswiki::cfg{EnableEmail} = $TRUE;

# **STRING 30**
@@ -1213,7 +1214,7 @@ $Foswiki::cfg{NotifyTopicName} = 'WebNotify';
# Send email Date header using local "server time" instead of GMT
$Foswiki::cfg{Email}{Servertime} = $FALSE;

#---++ Email Server Configuration
#---++ Email Server
# <p>Settings controlling if and how Foswiki sends email</p>

# **SELECT Net::SMTP,Net::SMTP::SSL, MailProgram **
@@ -1227,33 +1228,27 @@ $Foswiki::cfg{Email}{Servertime} = $FALSE;
# <ul><li><code>MailProgram</code> uses the program configured below to send email.
# Authentication and encryption is done externally to Foswiki and the remainder of
# the below fields are not used.
$Foswiki::cfg{Email}{MailMethod} = 'Net::SMTP';
#$Foswiki::cfg{Email}{MailMethod} = 'Net::SMTP';

# **COMMAND**
# Mail program. If Net::SMTP is installed, it will be used in preference.
# To force Foswiki to use the {MailProgram}, unset both {SMTP}{MAILHOST}
# below and all SMTPMAILHOST settings in your Foswiki's Preferences topics.
# This needs to be a command-line program that accepts
# MIME format mail messages on standard input, and mails them.
# To disable all outgoing email from Foswiki leave both this field and the
# MAILHOST field below blank.
$Foswiki::cfg{MailProgram} = '/usr/sbin/sendmail -t -oi -oeq';

# **BOOLEAN EXPERT**
# Set this option on to enable debug
# mode in SMTP. Output will go to the webserver error log.
# mode in SMTP. Output will go to the webserver error log
$Foswiki::cfg{SMTP}{Debug} = 0;

# **STRING 30**
# Mail host for outgoing mail. This is only used if Net::SMTP is installed.
# Examples: mail.your.company
# <b>CAUTION</b> This setting can be overridden by a setting of SMTPMAILHOST
# Examples: <tt>mail.your.company</tt> If the smtp server uses a different port
# than the default 25 # use the syntax <tt>mail.your.company:portnumber</tt>
# <p><b>CAUTION</b> This setting can be overridden by a setting of SMTPMAILHOST
# in SitePreferences. Make sure you delete that setting if you are using a
# SitePreferences topic from a previous release of Foswiki. To disable all
# outgoing mail from Foswiki leave both this field and the MailProgram field
# above blank. If the smtp server uses a different port than the default 25
# use the syntax <tt>mail.your.company:portnumber</tt>
# SitePreferences topic from a previous release of Foswiki.</p>
# <p>For Gmail, set MailMethod to Net::SMTP::SSL, set MAILHOST to <tt>smtp.gmail.com:465</tt>
# and provide your gmail email address and password below for authentication.</p>
$Foswiki::cfg{SMTP}{MAILHOST} = '';

# **STRING 30**
@@ -1273,8 +1268,8 @@ $Foswiki::cfg{SMTP}{Username} = '';
# Password for your {SMTP}{Username}.
$Foswiki::cfg{SMTP}{Password} = '';

#---++ S/MIME Configuration
# <p><b>NOT IMPLEMENTED</b></p>
#---++ S/MIME
# <p><b>S/MIME is only supported with external MailProgram like <code>sendmail</code></b></p>
# <p>Configure signing of outgoing email. (Secure/Multipurpose Internet Mail Extensions)
# is a standard for public key encryption and signing of MIME encoded email messages.
# Messages generated by the server will be signed using an X.509 certificate.</p>
@@ -1299,7 +1294,7 @@ $Foswiki::cfg{Email}{SmimeCertificateFile} = '$Foswiki::cfg{DataDir}/cert.pem';
# in the following settings.
$Foswiki::cfg{Email}{SmimeKeyFile} = '$Foswiki::cfg{DataDir}/key.pem';

#---++ Proxy Configuration
#---++ Proxy
# Some environments require outbound HTTP traffic to go through a proxy
# server. (e.g. http://proxy.your.company).
# **STRING 30**
@@ -0,0 +1,69 @@
# See bottom of file for license and copyright information

package Foswiki::Configure::Checkers::Email::EnableSMIME;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Foswiki::Configure::Load;

sub check {
my $this = shift;
my $e = '';

my $n =
$this->checkPerlModule( 'Crypt::SMIME', 'Required for S/MIME', 0.09 );

if ( $n =~ m/Not installed/ && $Foswiki::cfg{Email}{EnableSMIME} ) {
$e = $this->ERROR($n);
}
else {
$e = $this->NOTE($n);
}

return $e unless $Foswiki::cfg{Email}{EnableSMIME};

unless ( $Foswiki::cfg{Email}{MailMethod} eq 'MailProgram' ) {
$e .= $this->ERROR(
"S/MIME signing only supported with {Email}{MailMethod} of <code>MailProgram</code> - MailMethod is currenlty set to <code>$Foswiki::cfg{Email}{MailMethod}</code>"
);
$e .= $this->NOTE("See the Email Server Configuration tab");
}

$e .= $this->ERROR(
"Certificate and Key files must be provided for S/MIME email")
unless ( $Foswiki::cfg{Email}{SmimeCertificateFile}
&& $Foswiki::cfg{Email}{SmimeKeyFile} );

return $e;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
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. For
more details read LICENSE in the root of this distribution.
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.
As per the GPL, removal of this notice is prohibited.
@@ -0,0 +1,74 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Email::MailMethod;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

sub check {
my $this = shift;
my $n = '';

return '' if ( !$Foswiki::cfg{EnableEmail} );

if ( !$Foswiki::cfg{Email}{MailMethod} ) {
if ( $Foswiki::cfg{SMTP}{MAILHOST} ) {
$n .= $this->NOTE(
"MailMethod was not configured - I guessed <code>Net::SMTP</code>"
);
$Foswiki::cfg{Email}{MailMethod} = 'Net::SMTP';
$n .= $this->guessed(0);
}
else {
$n .= $this->NOTE(
"MailMethod was not configured - I guessed <code>MailProgram</code>"
);
$Foswiki::cfg{Email}{MailMethod} = 'MailProgram';
$n .= $this->guessed(0);
}

$n .= $this->WARN( <<HERE );
<b>Compatibility Note:</b> Previous version of Foswiki guessed the MailMethod at
runtime based upon the configuration setting of {SMTP}{MAILHOST}, and could be overridden
by a setting of SMTPMAILHOST in SitePreferences. If neither were set, it would try the
MailProgram. Once you save this configuration,
<ul>
<li>if MailMethod is set to MailProgram, the external mail method will always be used.
<li>If MailMethod is set to Net::SMTP or Net::SMTP::SSL, then the MAILHOST settings from the configuration as overridden by SitePreferences will be used.
<li>if Neither {SMTP}{MAILHOST} nor SMTPMAILHOST are set, then the MailProgram will be tried.
</ul>
It is recommended to delete the SMTPMAILHOST setting if you are using a SitePreferences topic from a previous release of Foswiki.
HERE
}

return $n;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
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. For
more details read LICENSE in the root of this distribution.
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.
As per the GPL, removal of this notice is prohibited.
@@ -0,0 +1,56 @@
# See bottom of file for license and copyright information

package Foswiki::Configure::Checkers::Email::SmimeCertificateFile;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Foswiki::Configure::Load;

sub check {
my $this = shift;

my $certFile = $Foswiki::cfg{Email}{SmimeCertificateFile} || "";

return unless $certFile;

Foswiki::Configure::Load::expandValue($certFile);
my $e = !-r ($certFile) && "Can\'t read $certFile";
if ($e) {
$e =
( $Foswiki::cfg{Email}{EnableSMIME} )
? $this->ERROR($e)
: $this->NOTE("<b>Note:</b> $e");
}
return $e;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
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. For
more details read LICENSE in the root of this distribution.
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.
As per the GPL, removal of this notice is prohibited.
@@ -0,0 +1,56 @@
# See bottom of file for license and copyright information

package Foswiki::Configure::Checkers::Email::SmimeKeyFile;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
use Foswiki::Configure::Load;

sub check {
my $this = shift;

my $keyFile = $Foswiki::cfg{Email}{SmimeKeyFile} || "";

return unless $keyFile;

Foswiki::Configure::Load::expandValue($keyFile);
my $e = !-r ($keyFile) && "Can\'t read $keyFile";
if ($e) {
$e =
( $Foswiki::cfg{Email}{EnableSMIME} )
? $this->ERROR($e)
: $this->NOTE("<b>Note:</b> $e");
}
return $e;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
TWiki Contributors are listed in the AUTHORS file in the root
of this distribution. NOTE: Please extend that file, not this notice.
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. For
more details read LICENSE in the root of this distribution.
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.
As per the GPL, removal of this notice is prohibited.
@@ -9,17 +9,37 @@ our @ISA = ('Foswiki::Configure::Checker');

sub check {
my $this = shift;
my $n = '';
my $n = '';

return '' if ( !$Foswiki::cfg{EnableEmail} );

if ( $Foswiki::cfg{Email}{MailMethod} eq 'MailProgram') {
if ( $Foswiki::cfg{Email}{MailMethod} eq 'MailProgram' ) {
my $val = $Foswiki::cfg{MailProgram} || '';
$val =~ s/\s.*$//g;
if ( !( -x $val ) ) {
$n .= $this->ERROR("<tt>$val</tt> was not found (but is required). Check the path, or configure one of the <code>Net::SMTP</code> methods..");
$n .= $this->ERROR(
"<tt>$val</tt> was not found (but is required). Check the path, or configure one of the <code>Net::SMTP</code> methods.."
);
}
}
else {
$n .= $this->NOTE(
"MailProgram is not used for the configued Email method: <code>$Foswiki::cfg{Email}{MailMethod}</code>"
);
}

if (
( $Foswiki::cfg{Email}{MailMethod} eq 'MailProgram' )
&& ( $Foswiki::cfg{SMTP}{MAILHOST}
|| $Foswiki::cfg{SMTP}{SENDERHOST}
|| $Foswiki::cfg{SMTP}{Username}
|| $Foswiki::cfg{SMTP}{Password} )
)
{
$n .= $this->NOTE(
"<b>Note:</b> None of the below parameters are used by the configured Email method $Foswiki::cfg{Email}{MailMethod}"
);
}
return $n;
}

0 comments on commit 0d4823b

Please sign in to comment.
You can’t perform that action at this time.