Skip to content

Commit

Permalink
Item12279: Work-around for IO:Socket::SSL misbehavior. Thanks to Geor…
Browse files Browse the repository at this point in the history
…ge Clark for testing.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@16212 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Dec 14, 2012
1 parent 7cf2aa6 commit d351840
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions core/lib/Foswiki/Net.pm
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ sub _installMailHandler {
require Foswiki::Sandbox;
$this->{MAIL_HOST} =
Foswiki::Sandbox::untaintUnchecked( $this->{MAIL_HOST} );
$this->{MAIL_METHOD} =
Foswiki::Sandbox::untaintUnchecked( $this->{MAIL_METHOD} );
eval "require $this->{MAIL_METHOD};";
if ($@) {
print STDERR ">>>> Failed to load $this->{MAIL_METHOD}: $@ \n";
Expand Down Expand Up @@ -563,7 +565,7 @@ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1 . $2 . $3 . _fixLineLength( $4 )/

my $smtp = 0;

my ( $host, $port ) = $this->{MAIL_HOST} =~ m/(.*):([0-9]{2-5})$/;
my ( $host, $port ) = $this->{MAIL_HOST} =~ m/^([^:]+)(?::([0-9]{2,5}))?$/;
my @options = ( Host => $host, );

push @options, Port => $port if ($port);
Expand All @@ -587,10 +589,27 @@ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1 . $2 . $3 . _fixLineLength( $4 )/
#}

if ( $this->{MAIL_METHOD} eq 'Net::SMTP::SSL' ) {
$smtp = Net::SMTP::SSL->new( $this->{MAIL_HOST}, @options );

package Foswiki::Net::Mail;
our @ISA = @Net::SMTP::ISA;

@Net::SMTP::ISA = __PACKAGE__;

sub new {
my $class = shift;
my $sock;
$sock =
IO::Socket::SSL->new( @_,
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE() )
and bless $sock, $class;

return $sock;
}

$smtp = Net::SMTP::SSL->new(@options);
}
else {
$smtp = Net::SMTP->new( $this->{MAIL_HOST}, @options );
$smtp = Net::SMTP->new(@options);
}

my $status = '';
Expand Down

0 comments on commit d351840

Please sign in to comment.