public ActionResult Send(MailObject message) { var response = SendSimpleMessage(message); var sentMail = new MailObject() { SendStatus = response.StatusDescription }; return RedirectToAction("Sent",sentMail); }
public ActionResult SendOrder(Order order) { var orderText = "<h3>You have a new order - {0}. </h3><br/><ul>Order Details <li>Number of Items : {1}</li><li>Name: {2}</li><li>Phone: {3}</li><li>Address: {4}</li></ul>"; var mailObject = new MailObject() { From = "*****@*****.**", Subject = "New Order", MessageText = "New order placed", MessageHtml = string.Format(orderText, DateTime.Now, order.NumberOfItems, order.CustomerName, order.CustomerPhoneNumber, order.CustomerAddress) }; var response = SendSimpleMessage(mailObject); return RedirectToAction("Order"); }
private static IRestResponse SendSimpleMessage(MailObject message) { RestClient client = new RestClient(); client.BaseUrl = "https://api.mailgun.net/v2"; client.Authenticator = new HttpBasicAuthenticator("api", "key-7u19qg14wsvhjnlkp61l3k5y1051im31"); RestRequest request = new RestRequest(); request.AddParameter("domain", "app2956.mailgun.org", ParameterType.UrlSegment); request.Resource = "{domain}/messages"; request.AddParameter("to", "*****@*****.**"); request.AddParameter("to", "*****@*****.**"); //request.AddParameter("to", "*****@*****.**"); request.AddParameter("from", message.From); request.AddParameter("subject", message.Subject); request.AddParameter("text", message.MessageText); request.AddParameter("html", message.MessageHtml); request.Method = Method.POST; return client.Execute(request); }
public ActionResult Sent(MailObject mail) { return View("Index",mail); }
public ActionResult Index() { var mail = new MailObject(); return View(mail); }