Packages
Simple library checking the validity of an email. Checks are performed in the following order: - REGEX: validate the emails has a good looking format - MX: validate the domain sever contains MX records - SMTP: validate the SMTP behind the MX records knows this email address (no email sent)
Current section
Files
Jump to
Current section
Files
lib/email_checker.ex
defmodule EmailChecker do
@validations [
&EmailChecker.Format.valid?/1,
&EmailChecker.MX.valid?/1,
&EmailChecker.SMTP.valid?/1,
]
def valid?(email) do
expected_length =
validations |> length
case validations |> Stream.take_while(&( &1.(email) )) |> Enum.to_list do
list when length(list) == expected_length ->
true
_ ->
false
end
end
defp validations do
@validations
end
end