diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 72972c3464e29a121b27a69562f4cbfd5f01bba2..10c2dff54093dc97b35bcacca42a261c3a13b7d6 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -415,7 +415,11 @@ sub req_generate_token {
             }
         );
     };
-    $self->{logger}->errorf("Error TT2 : %s", $EVAL_ERROR) if $EVAL_ERROR;
+    if ($EVAL_ERROR) {
+        push @{ $self->{out}->{errors} }, "mail_notification_error";
+        $self->{logger}->errorf("Mail notification error: %s", $EVAL_ERROR);
+        return undef;
+    }
 
     $self->{logger}->infof(
         "Token send to %s for sp_entityid=%s;token=%s",