Copied to clipboard

Flag this post as spam?

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

  • Chris Van Oort 110 posts 369 karma points
    Mar 20, 2018 @ 22:18
    Chris Van Oort

    Block disposable email addresses with Umbraco Forms?

    Hi -- does anyone know if it's possible to inject a layer of logic into umbraco forms to essentially block disposable email addresses?

    Right now someone fills out an Umbraco form, presses submit, it sends the data to us and Umbraco forms records it and then processes any workflows.

    I'd like to have someone fill out an Umbraco form, press submit, it sends the data to us, we check if it's a disposable email address, and if it's not we return a nondescript error to the user. If it's not a disposable, then Umbraco forms records it and then processes any workflows.

    I suspect it would be aking to how reCaptcha was integrated here, but I'm not 100%:

    Here's the github of the continually updated list of disposable email addresses:

    In another project (without Umbraco forms), I'm pulling the latest json file from there periodically and blocking users from registering with disposable emails.

    Best, Chris

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Mar 21, 2018 @ 05:38
    Nathan Woulfe

    Hi Chris

    You should be able to write a Forms' workflow to do this - will let you intercept the submission, examine the contents, and act on it.

    Try these docs as a starting point:

  • Chris Van Oort 110 posts 369 karma points
    Mar 21, 2018 @ 20:10
    Chris Van Oort

    @Nathan -- thanks! I hadn't considered that. When I was thinking about this yesterday I thought we should inject logic essentially on the server side as a type of "form validation." In that scenario, we'd essentially stop the form submission from even being recorded in Umbraco Forms.

    I think I like your idea of having a workflow operation to essentially check if it's a disposable email and then it can delete it if needed.

    In our site, we're also using PerplexMail to map Form workflows to emails to relevant stakeholders. (ie. User fills out form, we give feedback to the user or redirect them to a page, and the server sends an email to someone in the company). Do you know if the workflow item essentially can "stop processing" subsequent workflow items? If it can stop processing subsequent workflow items, then I can essentially delete the record and prevent an email from being sent to a stakeholder.

  • Chris Van Oort 110 posts 369 karma points
    May 21, 2018 @ 21:15
    Chris Van Oort

    Circling back to this in case anyone else runs across it; I didn't implement the workflow solution, but will likely implement something like the following in the future.

    The ideal solution for me was hooking and essentially preventing the data from getting to us in the first place. Thus utilizing our existing extension of the umbraco forms validator is the way to go.

    There's a few examples here:

    Then the part I found difficult was determining 'how' to get the form field data -- specifically the email field without needing to refactor all of our existing forms with a custom field. The code would look something like this:

    var emailField = e.Form.AllFields.Where(x => x.FieldType.Alias.ToLower().Contains("email")).FirstOrDefault(); var emailAddressValue = e.Context.Request[emailField.Id.ToString()];

    You'd have to change the .Contains("email") to be whatever a common word on your email address field is. You could also other forms of string comparison but this is quick/dirty and should work.

    Once you've got the email address you can search through the DB or cached list of bad email domains to search for a match (Stackoverflow has some nice examples of how to use Linq to search for a string match within a List

  • Liam Dilley 147 posts 373 karma points
    Nov 05, 2020 @ 04:57
    Liam Dilley

    A 2020 update on this one: What we did was to use the following:

    And create an event handler that checked the email field. You would either have something like a repeatable text string field somewhere in the back office you would add emails into and read from that or simpler have a string of comma seperate emails in a web config value and if the email coming through was one of those DON'T do anything.

Please Sign in or register to post replies

Write your reply to: