﻿// Copyright (c) 2018 Nikolay Zahariev <zahasoft.com>. Licensed under the MIT License.

namespace Zahasoft.Weblog.Services
{
    using Microsoft.AspNet.Identity;
    using System.Net;
    using System.Net.Mail;
    using System.Threading.Tasks;

    public class EmailService : IEmailService
    {
        public Task SendAsync(IdentityMessage message) =>
            new SmtpClient
            {
                Host = "smtp.live.com",
                Port = 587,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                EnableSsl = true,
                Credentials = new NetworkCredential("username", "password")
            }.SendMailAsync(new MailMessage("email", message.Destination, message.Subject, message.Body));
    }
}
