Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Craig 6 posts 76 karma points
    Feb 21, 2019 @ 11:43
    Craig
    0

    Add Recaptcha/Captcha to contact form

    Hello all,

    I could really do with some serious help here.

    Our website has a contact page that has no captcha in place as such we get a lot of spam type contacts which is causing the recipient some annoyance.

    I unfortunately have no web dev experience so really need some guidance on adding a captcha to the page.

    Our Umbraco version is 6.0.4 (Assembly version: 1.0.4863.23138)

    I have downloaded the EyeCatch ReCaptcha package but have no idea where to go from here.

    Regards

    Craig

  • Rhys Hamilton 140 posts 942 karma points
    Feb 21, 2019 @ 16:18
    Rhys Hamilton
    0

    Hi Craig,

    In order to add a ReCaptcha field to your current Umbraco V6, I think that some development experience will be required.

    The EyeCatch ReCaptcha package itself was originally designed to integrate with another package called Doc2Forms. Since it's over 9 year olds, there's no guarantee either of these will work smoothly (or at all).

    Personally, I'd recommend contacting the developer who put together the site for you if you can.

    Alternatively, If you have access to the site code, you might be able to contact a local Umbraco developer (or a member of the community) who might be able to help more with this.

  • Craig 6 posts 76 karma points
    Feb 21, 2019 @ 16:37
    Craig
    0

    Hi Rhys,

    I have access to the code and the server.

    Code is below

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @using System.Net.Mail;
    @using Recaptcha;
    @{
        var rootNode = Model.AncestorOrSelf(1);
        var contactPage = rootNode.DescendantsOrSelf("ContactUs")[0];
        var emailFrom = "";
        var subject = "";
        var emailTo = "";
    
        var prefix = Model.Id == 1270 ? "pt" : "en";
        var act = Model.Id == 1270 ? "contacte-nos" : "contact-us";
    
        if (IsPost) {
    
            var body = String.Empty;
            body += "Name: " + Request.Form["fullname"] + "
    "; body += "Company: " + Request.Form["company"] + "
    "; body += "Job Title: " + Request.Form["jobtitle"] + "
    "; body += "Telephone: " + Request.Form["telephone"] + "
    "; body += "Email: " + Request.Form["email"] + "
    "; body += "Subject: " + Request.Form["messagesubject"] + "
    "; body += "Type of Enquiry: " + Request.Form["mediainquiries"] + "
    "; body += "Comments: " + Request.Form["comments"] + "
    "; var mailObj = new MailMessage { From = new MailAddress(emailFrom), Subject = subject }; //Add To Addresses foreach (string email in emailTo.Split(',')) { string emailTrimmed = email.Trim(); if (!string.IsNullOrEmpty(emailTrimmed)) { mailObj.To.Add(new MailAddress(emailTrimmed)); } } //Build Body mailObj.IsBodyHtml = true; mailObj.Body = body; try { var smtp = new SmtpClient("smtp.office365.com", 587); smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("", ""); smtp.EnableSsl = true; smtp.Send(mailObj); } catch (Exception exc) { } Response.Redirect("/" + prefix + "/" + act + "/thanks"); } }
    @Html.Raw(contactPage.GetPropertyValue("contactFooter"))
  • Rhys Hamilton 140 posts 942 karma points
    Feb 22, 2019 @ 11:53
    Rhys Hamilton
    0

    Hi Craig,

    Since you have access to the code, then you should be able to add the ReCaptcha functionality yourself.

    There’s a few useful articles here on the forum and another on Codeshare that should take you through the process, or at least point you in the right direction.

    Again though, there will be a bit of development to get this setup for your particular scenario.

Please Sign in or register to post replies

Write your reply to:

Draft