{"id":13507836,"url":"https://github.com/Betree/burnex","last_synced_at":"2025-03-30T09:33:07.078Z","repository":{"id":28351410,"uuid":"118107404","full_name":"Betree/burnex","owner":"Betree","description":"📨🔥 Elixir burner email (temporary address) detector","archived":false,"fork":false,"pushed_at":"2024-08-14T13:33:13.000Z","size":507,"stargazers_count":76,"open_issues_count":9,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T00:46:07.049Z","etag":null,"topics":["burner-email","elixir","temporary-email"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/burnex/Burnex.html","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Betree.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-19T09:48:35.000Z","updated_at":"2025-02-19T11:38:36.000Z","dependencies_parsed_at":"2024-05-01T16:19:52.023Z","dependency_job_id":"4780648e-e277-4d84-8b25-bb5cf7fe03ba","html_url":"https://github.com/Betree/burnex","commit_stats":{"total_commits":68,"total_committers":14,"mean_commits":4.857142857142857,"dds":0.5588235294117647,"last_synced_commit":"7a66f17017d140e25e4df1c4e9fbc43b73656a91"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Betree%2Fburnex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Betree%2Fburnex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Betree%2Fburnex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Betree%2Fburnex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Betree","download_url":"https://codeload.github.com/Betree/burnex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246187241,"owners_count":20737462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["burner-email","elixir","temporary-email"],"created_at":"2024-08-01T02:00:40.533Z","updated_at":"2025-03-30T09:33:07.050Z","avatar_url":"https://github.com/Betree.png","language":"Elixir","funding_links":[],"categories":["Email"],"sub_categories":[],"readme":"# Burnex\n\n\u003c!--MDOC !--\u003e\n\n[![Build Status](https://github.com/Betree/burnex/workflows/Test/badge.svg)](https://github.com/Betree/burnex/actions)\n[![Coverage Status](https://coveralls.io/repos/github/Betree/burnex/badge.svg?branch=master)](https://coveralls.io/github/Betree/burnex?branch=master)\n[![Module Version](https://img.shields.io/hexpm/v/burnex.svg)](https://hex.pm/packages/burnex)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/burnex/)\n[![Total Download](https://img.shields.io/hexpm/dt/burnex.svg)](https://hex.pm/packages/burnex)\n[![License](https://img.shields.io/hexpm/l/burnex.svg)](https://hex.pm/packages/burnex)\n[![Last Updated](https://img.shields.io/github/last-commit/Betree/burnex.svg)](https://github.com/Betree/burnex/commits/master)\n\nCompare an email address against 3900+ burner email domains (temporary email\nproviders) based on this list from\n[https://github.com/wesbos/burner-email-providers](https://github.com/wesbos/burner-email-providers).\n\n## Installation\n\nAdd `:burnex` to your list of dependencies in `mix.exs`.\n\n```elixir\ndef deps do\n  [\n    {:burnex, \"~\u003e 3.1.0\"}\n  ]\nend\n```\n\n## Usage\n\nBe aware that Burnex will not check if the email is RFC compliant, it will only\ncheck the domain (everything that comes after `@`).\n\n```elixir\niex\u003e Burnex.is_burner?(\"my-email@gmail.com\")\nfalse\niex\u003e Burnex.is_burner?(\"my-email@yopmail.fr\")\ntrue\niex\u003e Burnex.is_burner? \"invalid.format.yopmail.fr\"\nfalse\niex\u003e Burnex.is_burner? \"\\\"this is a valid address! crazy right ?\\\"@yopmail.fr\"\ntrue\n\niex\u003e Burnex.providers |\u003e MapSet.member?(\"yopmail.fr\")\ntrue\n```\n\n### With an Ecto changeset\n\nFollowing code ensures email has a valid format then check if it belongs to a burner provider:\n\n```elixir\ndef changeset(model, params) do\n  model\n  |\u003e cast(params, @required_fields ++ @optional_fields)\n  |\u003e validate_required([:email])\n  |\u003e validate_email()\nend\n\n@email_regex ~r/\\A([\\w+\\-].?)+@[a-z\\d\\-]+(\\.[a-z]+)*\\.[a-z]+\\z/i\n\ndefp validate_email(%{changes: %{email: email}} = changeset) do\n  case Regex.match?(@email_regex, email) do\n    true -\u003e\n      case Burnex.is_burner?(email) do\n        true -\u003e add_error(changeset, :email, \"forbidden_provider\")\n        false -\u003e changeset\n      end\n    false -\u003e add_error(changeset, :email, \"invalid_format\")\n  end\nend\ndefp validate_email(changeset), do: changeset\n```\n\n### MX record DNS resolution\n\nAs an extra precaution against newly-created burner domains,\nyou can use Burnex to do MX record DNS resolution.\nThis is done like this:\n\n```\niex\u003e Burnex.check_domain_mx_record(\"gmail.com\")\n:ok\niex\u003e Burnex.check_domain_mx_record(\"gmail.dklfsd\")\n{:error, \"Cannot find MX records\"}\n```\n\nHere is an example function to check if an email is valid:\n\n```elixir\n  # Use a regex capture to get the \"domain\" part of an email\n  @email_regex ~r/^\\S+@(\\S+\\.\\S+)$/\n\n  # hard-code some trusted domains to avoid checking their MX record every time\n  @good_email_domains [\n    \"gmail.com\",\n    \"fastmail.com\"\n  ]\n\n  defp email_domain(email), do: Regex.run(@email_regex, String.downcase(email))\n\n  defp is_not_burner?(email, domain) do\n    with {:is_burner, false} \u003c- {:is_burner, Burnex.is_burner?(email)},\n         {:check_mx_record, :ok} \u003c- {:check_mx_record, Burnex.check_domain_mx_record(domain)} do\n      true\n    else\n      {:is_burner, true} -\u003e\n        {false, \"forbidden email\"}\n\n      {:check_mx_record, {:error, error_message}} when is_binary(error_message) -\u003e\n        {false, error_message}\n\n      {:check_mx_record, :error} -\u003e\n        {false, \"forbidden provider\"}\n    end\n  end\n\n  @spec is_valid?(String.t()) :: true | {false, String.t()}\n  def is_valid?(email) do\n    case email_domain(email) do\n      [_ | [domain]] when domain in @good_email_domains -\u003e\n        true\n\n      [_ | [domain]] -\u003e\n        is_not_burner?(email, domain)\n\n      _ -\u003e\n        {false, \"Email in bad format\"}\n    end\n  end\n```\n\n## License\n\nThis software is licensed under MIT license. Copyright (c) 2018- Benjamin Piouffle.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBetree%2Fburnex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBetree%2Fburnex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBetree%2Fburnex/lists"}