You are here: Foswiki>Tasks Web>Item12382 (28 Feb 2013, GeorgeClark)Edit Attach

Item12382: Failure sending multiple SSL email messages

pencil
Priority: Urgent
Current State: Closed
Released In: 1.1.8
Target Release: patch
Applies To: Engine
Component: FoswikiNet
Branches: Release01x01 trunk
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
When the Registration process attempts to send the 2nd message to the Wiki Administrator, the attempt fails with a error message in the web server error log. The registration still succeeds but the admin is not notified.

If the site is using persistent perl (FastCGI or Mod_perl) no further email can be sent.

A fix is being tested, but is not yet verified. Candidate fixes for trunk and Foswiki 1.1.7 are shown below.

| MAIL Error sending email to Wiki Administrator <admin@site.com> |
| MAIL  -- Recursive inheritance detected in package 'Foswiki::Net::Mail::SSL' at /var/www/foswiki/trunk/core/lib/Foswiki/Net.pm line 1144. |
| MAIL  --  at /var/www/foswiki/trunk/core/lib/Foswiki/Net.pm line 1144 |
| MAIL  -- \tFoswiki::Net::Mail::SSL::setup('Foswiki::Net=HASH(0x8d11840)', undef, undef, 'STARTTLS', 'site.org', 587, 0) called at /var/www/foswiki/trunk/core/lib/Foswiki/Net.pm line 886 |
| MAIL  -- \tFoswiki::Net::_sendEmailByNetSMTP('Foswiki::Net=HASH(0x8d11840)', 'Date: Sun, 03 Feb 2013 20:58:59 GMT\\x{a}From: Wiki Administrator ...') called at /var/www/foswiki/trunk/core/lib/Foswiki/Net.pm line 527 |

-- GeorgeClark - 03 Feb 2013

I don't see this for single recipient messages, like password resets. But it fails in user registration for the admin address. The registration message goes through fine. So it's the 2nd call to Net::senEmail.

-- GeorgeClark - 03 Feb 2013

This fails on 1.1.7 as well.

-- GeorgeClark - 03 Feb 2013

The following fix appears to fix the issue (trunk only, not 1.1.7). I'm not sure of the impact on a persistent perl configuration:

diff --git a/core/lib/Foswiki/Net.pm b/core/lib/Foswiki/Net.pm
index 8f09d3f..1116272 100644
--- a/core/lib/Foswiki/Net.pm
+++ b/core/lib/Foswiki/Net.pm
@@ -883,8 +883,11 @@ s/([\n\r])(From|To|CC|BCC)(\:\s*)([^\n\r]*)/$1 . $2 . $3 . _fixLineLength( $4 )/
     );
     push @options, Hello => $this->{HELLO_HOST} if ( $this->{HELLO_HOST} );
 
-    Foswiki::Net::Mail::SSL::setup( $this, $ssl, $tls, $starttls, $host, $port,
-        $debug );
+    unless ( $this->{SSLsetupDone} ) {
+        Foswiki::Net::Mail::SSL::setup( $this, $ssl, $tls, $starttls, $host, $port,
+            $debug );
+        $this->{SSLsetupDone} = 1;
+    }
 
     $this->_logMailError(
         'debug',

-- GeorgeClark - 03 Feb 2013

Or this alternative, which might be a bit better:

diff --git a/core/lib/Foswiki/Net.pm b/core/lib/Foswiki/Net.pm
index 8f09d3f..67951a8 100644
--- a/core/lib/Foswiki/Net.pm
+++ b/core/lib/Foswiki/Net.pm
@@ -1141,6 +1141,9 @@ our ( $host, $port, $usessl, $starttls, $logcx, $verified, @sockopts,
 sub setup {
     ( my ( $this, $ssl, $tls ), $starttls, $host, $port, $logcx ) = @_;
 
+    return if ( $this->{SSLsetupDone} );
+    $this->{SSLsetupDone} = 1;
+    
     @ISA = @Net::SMTP::ISA;
 
     $usessl = $ssl || $tls;

-- GeorgeClark - 03 Feb 2013

Different fix needed for Release 1.1.7

--- /home/gac/Foswiki/Foswiki-1.1.7/lib/Foswiki/Net.pm  2013-01-31 20:52:05.000000000 -0500
+++ Net.pm      2013-02-03 18:38:13.912588232 -0500
@@ -591,8 +591,9 @@
     if ( $this->{MAIL_METHOD} eq 'Net::SMTP::SSL' ) {
 
         package Foswiki::Net::Mail;
-        our @ISA = @Net::SMTP::ISA;
 
+        our @ISA;
+        @ISA = @Net::SMTP::ISA unless defined @ISA;
         @Net::SMTP::ISA = __PACKAGE__;
 
         sub new {

-- GeorgeClark - 03 Feb 2013

This issue is that PACKAGE is defined as Foswiki::Net::Mail

So the first time the code runs:
  • @ISA = @Net::SMTP::ISA,   @NET::SMTP::ISA = Foswiki::Net::Mail;

Second time through, @ISA now tries to be set to the modified @NET::SMTP::ISA which is already there resulting in the recursive error. I think a complete fix will be:

   package Foswiki::Net::Mail;
...
   our @ISA;
   unless ( defined @ISA ) {
      @ISA = @Net::SMTP::ISA ;
      @Net::SMTP::ISA = __PACKAGE__;
  }

-- GeorgeClark - 18 Feb 2013

The "unless defined @ISA" fix seems to work fine for both trunk and release 1.1. Checkin it in for now so that this task can be closed for 1.1.8.

-- GeorgeClark - 21 Feb 2013
 

ItemTemplate edit

Summary Failure sending multiple SSL email messages
ReportedBy GeorgeClark
Codebase 1.1.7, trunk
SVN Range
AppliesTo Engine
Component FoswikiNet
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:7898f08f3b1d distro:98f74374dc57
TargetRelease patch
ReleasedIn 1.1.8
CheckinsOnBranches Release01x01 trunk
trunkCheckins distro:98f74374dc57
Release01x01Checkins distro:7898f08f3b1d
Topic revision: r9 - 28 Feb 2013, GeorgeClark - This page was cached on 05 Dec 2016 - 19:34.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License