Esempio n. 1
0
        public ActionResult Contact(ContactForm form)
        {
            //From Stack Overflow 9726576
            //Look for a proxy address first
            form.ClientAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            // If there is no proxy, get the standard remote address
            if (form.ClientAddress == null || form.ClientAddress.ToLower() == "unknown")
                form.ClientAddress = Request.ServerVariables["REMOTE_ADDR"];

            if (!ReCaptcha.Validate(privateKey: ConfigurationManager.AppSettings["ReCaptcha-PrivateKey"]))
            {
                ModelState.AddModelError("", "One or more words entered in the Captcha Challenge were incorrect.");
            }

            if (!ModelState.IsValid) return View(form);

            IContactUsMailer mailer = new ContactUsMailer();

            //Email them with thanks
            mailer.ThankYou(form).Send();

            //Send to the site team
            mailer.UserContact(form).Send();

            return View("ContactThanks");
        }
Esempio n. 2
0
 public virtual MvcMailMessage ThankYou(ContactForm form)
 {
     ViewBag.form = form;
     return Populate(x =>
     {
         x.Subject = "Thanks for contacting theREVIEW!";
         x.ViewName = "ThankYou";
         x.IsBodyHtml = true;
         x.To.Add(form.Email);
     });
 }
Esempio n. 3
0
 public virtual MvcMailMessage UserContact(ContactForm form)
 {
     ViewBag.form = form;
     return Populate(x =>
     {
         x.Subject = "A message to theREVIEW from " + form.Name;
         x.ViewName = "UserContact";
         x.IsBodyHtml = true;
         x.To.Add(ConfigurationManager.AppSettings["contact-email"]);
         x.ReplyToList.Add(form.Email);
     });
 }