public ActionResult Index(ContactFormModel Model)
        {
            if (!ModelState.IsValid)
            {
                return(View(Model));
            }

            var messageBody = new StringBuilder();

            messageBody.AppendLine("######################################## <br /> <br />");
            messageBody.AppendLine("Ново съобщение от: " + Model.FirstName + " " + Model.LastName);
            messageBody.AppendLine("<br /> <br />");
            messageBody.AppendLine("######################################## <br /> <br />");
            messageBody.AppendLine("Телефон: " + Model.Phone);
            messageBody.AppendLine("<br /> <br />");
            messageBody.AppendLine("######################################## <br /> <br />");
            messageBody.AppendLine("Имейл: " + Model.Email);
            messageBody.AppendLine("<br /> <br />");
            messageBody.AppendLine("######################################## <br /> <br />");
            messageBody.AppendLine("Съобщение: " + Model.Message);
            messageBody.AppendLine("<br /> <br />");
            messageBody.AppendLine("######################################## <br /> <br />");
            EmailFunctions.SendEmail(ConfigurationManager.AppSettings["AdminEmail"], "Ново запитване от сайта fakturi.nl", messageBody.ToString());
            TempData["MessageIsSent"] = "Съобщението е изпратено успешно.";
            return(View(Model));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var model = new ContactFormModel();

            model.RecapSiteKey = RecaptchaSiteKey;// "6Ld8MGYUAAAAAF-agxDENNPPNukwYmf6q3Bsgp_M";
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult SubmitContact(ContactFormModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Email))
            {
                return(Content("Email required"));
            }

            try
            {
                MailMessage message = new MailMessage {
                    From = new MailAddress("*****@*****.**")
                };
                message.To.Add(new MailAddress("*****@*****.**"));

                message.Subject = "Feedback from CryptAByte: " + model.Email;
                message.Body    = string.Format(@"
From: {0}
{1}
", model.Name, model.Message);

                SmtpClient client = new SmtpClient();
                client.Send(message);
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(messageFile, model.Email + Environment.NewLine);
                System.IO.File.AppendAllText(messageFile, model.Message + Environment.NewLine);
                System.IO.File.AppendAllText(messageFile, ex + Environment.NewLine);

                return(Content("Message sent"));
            }


            return(Content("Message sent"));
        }
        public ActionResult Create([Bind("Email,LastName,Name,Message")] ContactFormModel cfm)
        {
            using (var message = new MailMessage(cfm.Email, "*****@*****.**"))
            {
                //message.To.Add(new MailAddress("*****@*****.**"));
                // message.From = new MailAddress(cfm.Email);
                message.Subject = "New E-Mail from my website";
                message.Body    = cfm.Message;

                using (var smtpClient = new SmtpClient("smtp.mail.uni-kiel.de"))
                {
                    smtpClient.Send(message);
                }
            }


            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction(nameof(Create)));
            }
            catch
            {
                return(View("CreateContactEmail"));
            }
        }
Esempio n. 5
0
        public void Index([FromBody] ContactFormModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmailMessage msgToSend = new EmailMessage
                    {
                        FromAddresses = new List <EmailAddress> {
                            FromAndToEmailAddress
                        },
                        ToAddresses = new List <EmailAddress> {
                            FromAndToEmailAddress
                        },
                        Content = $"Sveiki Laima,<br /><br /> Gavote naują laišką:<br /><br /> <b>Vardas: </b> " + model.Name +
                                  "<br /><b>El.pašto adresas: </b>" + model.Email +
                                  "<br /><b>Tel.nr. : </b>" + model.TelNo +
                                  "<br /><b>Žinutė:</b>" + model.Message +
                                  "<br /><br /> Geros dienos!",
                        Subject = "Gavote laišką"
                    };

                    EmailService.Send(msgToSend);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }
Esempio n. 6
0
        public IActionResult Contact(ContactFormModel model, EmailAddress information)
        {
            if (ModelState.IsValid)
            {
                MailKitEmailService emailService = new MailKitEmailService(new EmailServerConfiguration());
                EmailMessage        msgToSend    = new EmailMessage
                {
                    FromAddresses = new List <ContactFormModel> {
                        model
                    },
                    ToAddresses = new List <EmailAddress> {
                        information
                    },
                    Content = $"Message From {model.Name} \n" +
                              $"Email: {model.Email} \n" + $"Message: {model.Message}",
                    Subject = "Contact Form"
                };

                emailService.Send(msgToSend);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(Contact());
            }
        }
Esempio n. 7
0
        public IActionResult sendMessage(ContactFormModel model)
        {
            if (ModelState.IsValid)
            {
                EmailMessage msgToSend = new EmailMessage
                {
                    FromAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    ToAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    Content = $"Name: {model.Name}, " +
                              $"Email: {model.EmailAddress}, Message: \n\n{model.Message}",
                    Subject = $"[vallenteen.com] Message from {model.Name}"
                };

                EmailService.Send(msgToSend);
                return(Ok());
            }
            else
            {
                return(BadRequest("Message could not be sent"));
            }
        }
        public IActionResult Index(ContactFormModel model)
        {
            try
            {
                MailMessage message = new MailMessage();
                message.From    = new MailAddress(model.Email);
                message.Subject = model.Subject;
                message.Body    = model.Message + Environment.NewLine + "Sender: " + model.Email;
                message.To.Add(ContactSubject);
                SmtpClient smtp = new SmtpClient();

                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;

                smtp.Credentials = new System.Net.NetworkCredential
                                       (ContactCredentialsEmail, ContactCredentialsPassword);
                smtp.EnableSsl = true;
                smtp.Send(message);

                ModelState.Clear();
                TempData.AddSuccessMessage("Your email is received.");
            }
            catch (Exception ex)
            {
                TempData.AddSuccessMessage(ex.ToString());
            }
            return(RedirectToAction("Index", "Home"));
        }
        // Brute Force getting rid of my worst emails
        private SpamState VerifyNoSpam(ContactFormModel model)
        {
            var tests = new string[]
            {
                "improve your seo",
                "improved seo",
                "generate leads",
                "viagra",
                "your team",
                "PHP Developers",
                "working remotely",
                "google search results",
                "link building software"
            };

            if (tests.Any(t =>
            {
                return(new Regex(t, RegexOptions.IgnoreCase).Match(model.Message).Success);
            }))
            {
                return(new SpamState()
                {
                    Reason = "Spam Email Detected. Sorry."
                });
            }
            return(new SpamState()
            {
                Success = true
            });
        }
Esempio n. 10
0
        public ActionResult Contact(ContactFormModel model)
        {
            if (ModelState.IsValid)
            {
                #region todo if valid
                MailMessage message = new MailMessage();
                SmtpClient  client  = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"]);
                message.To.Add(ConfigurationManager.AppSettings["AdminMail"]);
                message.From    = new MailAddress(model.AuthorEmail);
                message.Subject = model.Object;
                message.Body    = $"<p> Auteur: {model.AuthorEmail}</p> <p>Contenu: <br/> {model.Content}</p>";

                client.Port        = int.Parse(ConfigurationManager.AppSettings["SMTPPort"]);
                client.EnableSsl   = true;
                client.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["SMTPUser"], ConfigurationManager.AppSettings["SMTPPwd"]);

                client.Send(message);
                TempData["SuccessMessage"] = "Votre email a bien été envoyé";
                return(RedirectToAction("Home"));

                #endregion
            }
            ViewBag.ErrorMessage = "Le formulaire n'est pas valide";
            return(View(model));
        }
Esempio n. 11
0
        public async Task <IActionResult> SendMessage([FromBody] ContactFormModel form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var spamState = VerifyNoSpam(form);
                    if (!spamState.Success)
                    {
                        _logger.LogError("Spamstate wasn't succeeded");
                        return(BadRequest(new { Reason = spamState.Reason }));
                    }

                    // Captcha
                    if (!(await _captcha.Verify(form.Recaptcha)))
                    {
                        return(BadRequest("Failed to send email: You might be a bot...try again later."));
                    }
                    if (await _mailService.SendMailAsync("ContactTemplate.txt", form.Name, form.Email, form.Subject, form.Message))
                    {
                        return(Json(new { success = true, message = "Your message was successfully sent." }));
                    }
                }
                _logger.LogError("Modelstate wasnt valid");
                return(Json(new { success = false, message = "ModelState wasnt valid..." }));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to send email from contact page", ex.Message);
                return(Json(new { success = false, message = ex.Message }));
            }
        }
Esempio n. 12
0
        public void SendMail(ContactFormModel model)
        {
            var message = new MimeMessage();

            message.To.Add(new MailboxAddress("*****@*****.**"));
            message.From.Add(new MailboxAddress(model.SenderName, model.SenderMail));

            message.Subject = model.Subject;
            message.Body    = new TextPart(TextFormat.Text)
            {
                Text = model.Content
            };

            using (var emailClient = new SmtpClient())
            {
                emailClient.ServerCertificateValidationCallback = (s, c, h, e) => true;
                emailClient.Connect(_emailConfiguration.SmtpServer, _emailConfiguration.SmtpPort);

                emailClient.AuthenticationMechanisms.Remove("XOAUTH2");
                emailClient.Authenticate(_emailConfiguration.SmtpUsername, _emailConfiguration.SmtpPassword);

                emailClient.Send(message);

                emailClient.Disconnect(true);
            }
        }
Esempio n. 13
0
        public IActionResult Index(ContactFormModel model)
        {
            if (ModelState.IsValid)
            {
                EmailMessage msgToSend = new EmailMessage
                {
                    FromAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    ToAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    Content = $"Name: {model.Name} " + "<br/>" +
                              $"Email: {model.Email} " + "<br/>" +
                              $"Message: {model.Message}",
                    Subject = "Contact Form - MVC Site"
                };

                EmailService.Send(msgToSend);
                return(RedirectToAction("ContactThanks"));
            }
            else
            {
                return(Index());
            }
        }
Esempio n. 14
0
        public async Task <ActionResult> Privacy(ContactFormModel model)
        {
            try
            {
                var body = "<p>Email From: {0} {1}({3})</p><p>Message:</p><p>{2}</p>";
                using (MailMessage message = GetMessage())
                {
                    message.To.Add(new MailAddress(""));      // recepient
                    message.From       = new MailAddress(""); // sender
                    message.Subject    = "Your email subject";
                    message.Body       = string.Format(body, model.FirstName, model.LastName, model.Email, model.Feedback);
                    message.IsBodyHtml = true;

                    using (var smtp = new SmtpClient())
                    {
                        var credential = new NetworkCredential
                        {
                            UserName = "", // [email protected]
                            Password = ""  // password of your gmail account
                        };
                        smtp.Credentials = credential;
                        smtp.Host        = "smtp.gmail.com";
                        smtp.Port        = 587;
                        smtp.EnableSsl   = true;
                        await smtp.SendMailAsync(message);

                        return(RedirectToAction("Sent"));
                    }
                }
            }
            catch {
                return(View());
            }
        }
    public async Task <bool> AddAsync(ContactFormModel contactForm)
    {
        var sendRequest =     //...removed for clarity
                          var response = await sqsClient.SendMessageAsync(sendRequest);

        return(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
    }
        public ActionResult SubmitContactForm(ContactFormModel formData)
        {
            formData.SubmitTime = DateTime.Now;

            _contactService.Create(formData);
            return(Content("Form Succesfully Submitted"));
        }
        public IActionResult Index(ContactFormModel model)
        {
            if (!ModelState.IsValid)
            { // re-render the view when validation failed.
                return(View("Contact", model));
            }


            else if (ModelState.IsValid)
            {
                EmailMessage msgToSend = new EmailMessage
                {
                    FromAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    ToAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    Content = $"Here is your message: Name: {model.Name}, " +
                              $"Email: {model.Email}, Message: {model.Message}, Mobile:{model.Phone}",
                    Subject = "Contact Form - michaelwalsh.tech"
                };

                EmailService.Send(msgToSend);
                return(RedirectToAction("Success"));
            }
            else
            {
                return(Index());
            }
        }
Esempio n. 18
0
        public ActionResult SendContact(ContactFormModel model)
        {
            var contact = CurrentPage as Contact;

            //Set the fields that need to be replaced.
            var formFields = new Dictionary <string, string>
            {
                { "Name", model.Name },
                { "Email", model.Email },
                { "Phone", model.Phone },
                { "Message", model.Message }
            };

            //Send the e-mail with the filled in form data.
            Umbraco.ProcessForms(formFields, contact.Email, EmailType.Contact);

            //Redirect to the succes page.
            var child = CurrentPage.Children.FirstOrDefault();

            if (child != null)
            {
                return(RedirectToUmbracoPage(child));
            }

            return(RedirectToCurrentUmbracoPage());
        }
Esempio n. 19
0
        public HttpResponseMessage Put(ContactFormInfo form)
        {
            try
            {
                var model = ContactFormModel.Load(form.Id);
                model.MarkOld();
                switch (form.Type)
                {
                case "public":
                    model.Public = form.Checked;
                    break;

                case "read":
                    model.Read = form.Checked;
                    break;
                }
                model.MarkDirty();
                model.Save();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 20
0
        public ActionResult SendContact(ContactFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            //Set the fields that need to be replaced.
            var formFields = new Dictionary <string, string>
            {
                { "Name", model.Name },
                { "Email", model.Email },
                { "Comment", model.Comment }
            };

            //Send the e-mail with the filled in form data.
            ProcessForms(formFields, EmailType.Contact, "emailUser", "emailCompany");

            //Redirect to the succes page.
            var child = CurrentPage.Children.FirstOrDefault();

            if (child != null)
            {
                return(RedirectToUmbracoPage(child));
            }

            return(RedirectToCurrentUmbracoPage());
        }
Esempio n. 21
0
        public void sendMailByGmail(ContactFormModel model)
        {
            var    fromAddress  = new MailAddress("*****@*****.**", "To MHShop");
            var    toAddress    = new MailAddress("*****@*****.**", "To MHShop");
            string fromPassword = "******";
            string subject      = "Shop Request";
            string body         = model.Name + "\n" + model.Email + "\n" + model.Message;

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = true,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject + " / " + model.Email,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
Esempio n. 22
0
        public IActionResult FormHandler(ContactFormModel model)
        {
            if (ModelState.IsValid)
            {
                EmailMessage msgToSend = new EmailMessage
                {
                    FromAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    ToAddresses = new List <EmailAddress> {
                        FromAndToEmailAddress
                    },
                    Content = $"Here is your message: Name: {model.Name}, " +
                              $"Email: {model.Email}, Message: {model.Message}",
                    Subject = "Contact Form - BasicContactForm App"
                };

                EmailService.Send(msgToSend);
                return(RedirectToAction("ContactMe"));
            }
            else
            {
                return(RedirectToAction("ContactMe"));
            }
        }
Esempio n. 23
0
        public static void SendNotification(ContactFormModel model)
        {
            string template = GetEmailTemplate("TooksCms.ServiceLayer.EmailTemplates.ContactFormMail.txt");

            template = template.Replace("##NAME##", model.Name).Replace("##DATE##", model.Date.ToShortDateString() + " " + model.Date.ToShortTimeString()).Replace("##COMMENT##", model.Comment);

            SendNotification("Someone Has Contacted You | Digital Ectoplasm", template);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ContactFormModel contactForm = _contactRepository.GetWhere(x => x.Id == id).FirstOrDefault();

            _contactRepository.Delete(contactForm);

            return(RedirectToAction("Index"));
        }
        public bool ContactFormEmail(ContactFormModel contactForm)
        {
            MailboxAddress ContactInquiry = new MailboxAddress("Contact Inquiry", "*****@*****.**");

            bool IsSuccess = _responseBuilder.ContactFormAutoResponse(ContactInquiry, contactForm);

            return(IsSuccess);
        }
Esempio n. 26
0
 public ContactFormPage FillinFields(ContactFormModel contactForm)
 {
     FirstNameField.SendKeys(contactForm.FirstName);
     LastNameField.SendKeys(contactForm.LastName);
     CountrySelect.SendKeys(contactForm.Country);
     SubjectField.SendKeys(contactForm.Subject);
     return(this);
 }
        public async Task <bool> AddFormDetails(ContactFormModel forms)
        {
            _ = await _dbContext.AddAsync(forms);

            var saved = await _dbContext.SaveChangesAsync() > 0;

            return(saved);
        }
Esempio n. 28
0
        public ActionResult SubmitContactForm(ContactFormModel model) //Use ActionResult to handle the user interaction
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            //Check if reCAPTCHA has a result
            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                return(CurrentUmbracoPage());

                /* If it's an USkinned Umbraco Site:
                 *  return JavaScript("$('#recaptchaErrorMsg').show();$('#recaptchaErrorMsg').html('The reCAPTCHA field is required.');");
                 */
            }
            else
            {
                //Check if reCAPTCHA has a success result
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect!");
                    return(CurrentUmbracoPage());

                    /* If it's an USkinned Umbraco Site:
                     *  return JavaScript("$('#recaptchaFailMsg').show();$('#recaptcahFailMsg').html('The reCAPTCHA is incorrect!');");
                     */
                }
            }

            //Check if the data posted is valid
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());

                /* If it's an USkinned Umbraco Site:
                 *  return JavaScript(String.Format("$(ContactError{0}).show();$(ContactError{0}).html('{1}');", model.CurrentNodeID, HttpUtility.JavaScriptStringEncode(umbraco.library.GetDictionaryItem("USN Contact Form General Error"))));
                 */
            }

            string managerEmail = CurrentPage.HasValue("notifyEmail") ? CurrentPage.GetPropertyValue <string>("notifyEmail") : string.Empty;

            //Send email to manager
            SendNotificationToManager(model, managerEmail);

            //Send an auto replied email back to the clients
            SendAutoResponder(model);

            //Check if redirectionPage Url is empty
            var redirectionPage = CurrentPage.GetPropertyValue <Link>("redirection");

            //If it is, then redirect page to the Home page
            if (string.IsNullOrWhiteSpace(redirectionPage?.Url))
            {
                return(this.RedirectToUmbracoPage(CurrentPage.Site()));
            }
            //Otherwise, redirect it to the redirection page
            return(this.Redirect(redirectionPage.Url));
        }
Esempio n. 29
0
        public IActionResult Submit(ContactFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            return(Submit(model));
        }
Esempio n. 30
0
        public IActionResult SendContact([FromRoute] string orgId, ContactFormModel userInput)
        {
            _emailService.SendEmail(
                userInput.Name, userInput.Email,
                "City of Ideas", "*****@*****.**",
                "Contact Form", userInput.Message
                );

            return(RedirectToAction("Index", "Contact", new { orgId }));
        }