public void Add(User item) { item.DateCreated = DateTime.Now; item.Password = MySecurity.GetHashString(item.Password); _userRepository.Add(item); EmailModel m = new EmailModel(); m.To = item.Email.TrimEnd(); m.From = "*****@*****.**"; m.Subject = "Registration"; m.Body = "You have been successfuly registeren on our site!"; _emailService.SendEmail(m); }
public void Edit(User item) { if (_userRepository.isActive(item.UId) && !item.IsActive) { EmailModel m = new EmailModel(); m.To = item.Email.TrimEnd(); m.From = "*****@*****.**"; m.Subject = "You are banned"; m.Body = string.Format("Sorry, but you are banned on our site. Reason:{0}.",item.BlockDescription); _emailService.SendEmail(m); } _userRepository.Edit(item); }
public void SendEmail(EmailModel email) { if (Config == null) return; System.Net.Mail.MailMessage mail = new MailMessage(); mail.To.Add(email.To); mail.From = new MailAddress( email.From); mail.Subject = email.Subject; mail.Body = email.Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient { Host = Config.Get("Client"), Port = int.Parse(Config.Get("SMTPPort")), UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential (Config.Get("EmailName"), Config.Get("EmailPassword")), EnableSsl = bool.Parse(Config.Get("EnableSSL")) }; smtp.Send(mail); }