diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm index b6507fe98fcbb4af5cc856ec94a310a35ed6ab81..6776d9d9ba6c8f235d8b5633f339b960573288ee 100644 --- a/lib/IdPAccountManager/Tools.pm +++ b/lib/IdPAccountManager/Tools.pm @@ -112,11 +112,6 @@ sub mail_notice { my (%args) = @_; my $tt2_file = $args{template}; my $mail_data = $args{data}; - my $logger = $args{logger}; - - $logger->tracef( - sprintf('(template=%s, to=%s)', $args{template}, $args{to}) - ); open SENDMAIL, "|/usr/sbin/sendmail -f $args{from} $args{to}"; @@ -125,9 +120,9 @@ sub mail_notice { FILTERS => { qencode => [ \&qencode, 0 ] }, INCLUDE_PATH => $args{templates_dir} }); - unless ($tt2->process($tt2_file, $mail_data, \*SENDMAIL)) { - $logger->errorf("Error TT2 : %s", $tt2->error()); - } + $tt2->process($tt2_file, $mail_data, \*SENDMAIL) + or die $tt2->error(); + close SENDMAIL; } diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 2b107f0278a697f9eb6991deca899018cda9aa12..6b97aa34731ed3e867fbb92f287bbadf25c738ec 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -185,14 +185,16 @@ sub respond { ## Mail notification of admins about the error if (@errors_admin) { $self->{out}->{subject} = 'Error notification - web interface'; - IdPAccountManager::Tools::mail_notice( - template => 'mail/notification_generic_error.tt2.eml', - templates_dir => $self->{configuration}->{templates_dir}, - data => $self->{out}, - logger => $self->{logger}, - to => $self->{configuration}->{admin_email}, - from => $self->{configuration}->{notice_from} - ); + eval { + IdPAccountManager::Tools::mail_notice( + template => 'mail/notification_generic_error.tt2.eml', + templates_dir => $self->{configuration}->{templates_dir}, + data => $self->{out}, + to => $self->{configuration}->{admin_email}, + from => $self->{configuration}->{notice_from} + ); + }; + $self->{logger}->errorf("Error TT2 : %s", $EVAL_ERROR) if $EVAL_ERROR; } } @@ -409,14 +411,16 @@ sub req_generate_token { $self->{out}->{subtitle} = 'Generate an authentication token'; ## Send the challenge email with the token - IdPAccountManager::Tools::mail_notice( - template => 'mail/send_authentication_token.tt2.eml', - templates_dir => $self->{configuration}->{templates_dir}, - from => $self->{configuration}->{notice_from} - to => $self->{in}->{email_address}, - data => $self->{out}, - logger => $self->{logger} - ); + eval { + IdPAccountManager::Tools::mail_notice( + template => 'mail/send_authentication_token.tt2.eml', + templates_dir => $self->{configuration}->{templates_dir}, + from => $self->{configuration}->{notice_from} + to => $self->{in}->{email_address}, + data => $self->{out}, + ); + }; + $self->{logger}->errorf("Error TT2 : %s", $EVAL_ERROR) if $EVAL_ERROR; $self->{logger}->infof( "Token send to %s for sp_entityid=%s;token=%s",