Tags:
create new tag
, view all tags

Bug: Errors from Net::SMTP not displayed

When TWiki tries to send a mail (eg. during User Registration) with Net::SMTP, it doesn't report the specific error ( eg. "Sender Domain yourcompany.net must resolve" smile ) back to the user.

All you get is

  ERROR: Can't send mail using Net::SMTP

Additionally, the code in lib/TWiki/Net.pm does not detect all possible errors.

Suggestedd Patch:

*** Net.pm      2002/11/27 18:03:25     1.1
--- Net.pm      2002/11/27 18:09:17
***************
*** 184,197 ****
      } else {
          $smtp = Net::SMTP->new( $mailHost );
      }
!     $smtp->mail( $from );
!     $smtp->to( @to, { SkipBad => 1 } );
!     $smtp->data( $data );
!     $smtp->dataend();
      
      # I think this has to occur before the $smtp->quit, 
      # otherwise we'll miss the status message for the sending of the mail.
!     my $status = ($smtp->ok() ? "" : "ERROR: Can't send mail using Net::SMTP" );
  
      $smtp->quit();
      return $status;    
--- 184,199 ----
      } else {
          $smtp = Net::SMTP->new( $mailHost );
      }
!     {
!       $smtp->mail( $from ) or last;
!       $smtp->to( @to, { SkipBad => 1 } ) or last;
!       $smtp->data( $data ) or last;
!       $smtp->dataend() or last;
!     }
      
      # I think this has to occur before the $smtp->quit, 
      # otherwise we'll miss the status message for the sending of the mail.
!     my $status = ($smtp->ok() ? "" : "ERROR: Can't send mail using Net::SMTP :".$smtp->message );
  
      $smtp->quit();
      return $status;    

-- DonaldBuczek - 27 Nov 2002

Follow up

Thanks for the patch! There has been some improvement in error handling in this area - please try the TWikiAlphaRelease and then produce a patch against this, using the PatchGuidelines.

-- RichardDonkin - 28 Nov 2002

Fix record

Since it is a simple change I already put it into TWikiAlphaRelease. Thanks for the contribution.

-- PeterThoeny - 28 Nov 2002

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2002-11-28 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.