rustyswayne/Buzz.Hybrid — pull request #8 by JimBobSquarePants (2014-10-21 19:57:09+00:00)
Title: Fixing SMTP mailer

It is unwise to use Task.Factory.StartNew in ASP.NET

The update uses the old NET 2.0 asynchronous send method in order to maintain compatibility but realistically it should be using the new awaitable methods. This requires async all the way up though to the calling ActionResult.

e.g.

```
///

/// Sends an email asynchronously, logging any errors.
///

///
/// The to send.
///
///
/// The s containing identity credentials.
///
///
/// True if the email is sent successfully; otherwise, false.
///
public async Task SendAsync(MailMessage msg, NetworkCredential credentials = null)
{
try
{
// We want to send the email async
using (SmtpClient smtpClient = new SmtpClient { Credentials = credentials ?? CredentialCache.DefaultNetworkCredentials })
{
await smtpClient.SendMailAsync(msg);
}

return true;
}
catch (Exception ex)
{

LogHelper.Error("Buzz.Hybrid.Net.SmtpMailer failed sending email", ex);
return false;
}
}
```