using System.Configuration; using System.Net.Mail; using MileageTraker.Web.Models; using log4net; namespace MileageTraker.Web.Email { /// /// Email Notification /// public class EmailNotificationService { //private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly string _resetPasswordBody; private readonly string _resetPasswordFromAddress; private readonly string _resetPasswordSubject; private readonly SmtpClient _smtpClient; /// /// Initializes a new instance of the class. /// /// The SMTP client. public EmailNotificationService() { _smtpClient = new SmtpClient(); _resetPasswordBody = ConfigurationManager.AppSettings["ResetPasswordBody"]; _resetPasswordFromAddress = ConfigurationManager.AppSettings["ResetPasswordFromAddress"]; _resetPasswordSubject = ConfigurationManager.AppSettings["ResetPasswordSubject"]; } /// /// Sends the reset password email. /// /// To this user. /// Reset url public void NotifyResetPassword(User user, string url) { var body = string.Format(_resetPasswordBody, url); _smtpClient.Send(new MailMessage(_resetPasswordFromAddress, user.Email, _resetPasswordSubject, body)); } } }