http://www.perlmonks.org?node_id=637190


in reply to Error message not showing up from Net::SMTP

What do you mean by "the failure is silent"? Your output clearly shows auth communicated the failure.

Do you mean the error isn't in $!? $!'s content are meaningless unless a system call returned an error. You didn't make any system calls, much less one that returned an error. Perhaps you want $mail->code and/or $mail->message? (Remember, Net::SMTP objects are descendant of Net::Cmd.)

Replies are listed 'Best First'.
Re^2: Error message not showing up from Net::SMTP
by sg (Pilgrim) on Sep 05, 2007 at 17:25 UTC
    The message in the output came from user code when auth() returned false. The Net::SMTP module has the set status line:
    $self->set_status(500, ["Need MIME::Base64 and Authen::SASL todo auth" +]), return 0;
    Why didn't the precise error message "Need MIME::Base64 and Authen::SASL todo auth" get to the end-user? Or what exactly should the user have done differently in the user-code to have gotten that precise, informative error message?
      Replace
      print "ERROR: Could not authenticate user $user_id\n$!\n";
      with
      print "ERROR: Could not authenticate user $user_id\n$: ".$mail->messa +ge."\n";
      or equivalent.
        Thanks for the details. Augmenting the print statement with
        $mail->code,':',$mail->message,"\n";
        does indeed display the desired error message.
      Perhaps you should read my entire post instead of focusing on the rhetorical question. It explains why the message isn't returned via $!, and where it can be found.