Ive been building my online system and i want to add report errors area. It will show simple mail form and send mail to one specific address. I can send my email when I have the same address as receiver. But how I can send to him messages from various mails? This is my model for Email class :
[Required, Display(Name = "Name")]
public string FromName { get; set; }
[Required, Display(Name = "Mail"), EmailAddress]
public string FromMail { get; set; }
[Required, Display(Name = "Subject")]
public string Subject { get; set; }
[Required]
public string Message { get; set; }
And this is my Controller :
public ActionResult Send()
{
return View();
}
[HttpPost]
public ActionResult Send( NotificationFromUser user)
{
if (ModelState.IsValid)
{
MailMessage _mail = new MailMessage(user.FromMail, "specific receiver mail - admin");
_mail.Subject = user.Subject;
_mail.Body = user.Message;
SmtpClient smtpClient = new SmtpClient("smtp credentials", 587);
smtpClient.Credentials = new System.Net.NetworkCredential()
{
UserName = "",
Password = ""
};
smtpClient.EnableSsl = true;
smtpClient.Send(_mail);
return RedirectToAction("MessageSent");
}
return View();
}
Any ideas how I can modify my controller?