diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm index 8b64b1dc805ba32531b224350824d83c7b323898..697131dcdb14c102ae7b38f337d9330e6f97e1a5 100755 --- a/lib/IdPAccountManager/WebRequest.pm +++ b/lib/IdPAccountManager/WebRequest.pm @@ -365,11 +365,11 @@ sub req_generate_token { my $sender = $self->{configuration}->{notice_from}; my $recipient = $self->{in}->{email_address}; - unless (open(SENDMAIL, "|/usr/sbin/sendmail -f $sender $recipient")) { + open(my $handle, '|-', "/usr/sbin/sendmail -f $sender $recipient") or do { push @{ $self->{out}->{errors} }, "mail_notification_error"; - $self->{logger}->errorf("Mail notification error: %s", $ERRNO); + $self->{logger}->errorf("Unable to run sendmail executable: %s", $ERRNO); return undef; - } + }; my $tt2 = Template->new({ INCLUDE_PATH => $self->{configuration}->{templates_dir} @@ -391,13 +391,13 @@ sub req_generate_token { authentication_token => $token->token(), }; - unless ($tt2->process($template, $data, \*SENDMAIL)) { + unless ($tt2->process($template, $data, $handle)) { push @{ $self->{out}->{errors} }, "mail_notification_error"; $self->{logger}->errorf("Mail notification error: %s", $EVAL_ERROR); return undef; } - close SENDMAIL; + close $handle; $self->{logger}->infof( "Token send to %s for sp_entityid=%s;token=%s",