private void ReleaseClient() { try { _emailClient.Close(); } catch (Exception e) { _logger.LogError(e, $"Unexpected Error thrown while Closing _emailClient."); } }
public string SendEmail(Email email) { _logger.LogInformation($"Sending email to {email.To}"); try { _emailClient.SendEmail(email.To, email.Body); return("Success!"); } catch (Exception e) { _logger.LogError(e, $"Error sending email to {email.To}"); return("Failure."); } finally { _emailClient.Close(); } }
//Separate Close() Method for unit testing public string Close() { _emailClient.Close(); return("Success!"); }
public IActionResult Logout() { _emailClient.Close(); return(RedirectToAction("Index")); }