Wrap $mail call in onError in try/catch block (backport).