diff --git a/lib/asciinema/emails.ex b/lib/asciinema/emails.ex index e64f3f995..feb00e61c 100644 --- a/lib/asciinema/emails.ex +++ b/lib/asciinema/emails.ex @@ -10,16 +10,22 @@ defmodule Asciinema.Emails do "signup" -> job.args["to"] |> Email.signup_email(job.args["url"]) - |> Mailer.deliver_now!() + |> deliver() "login" -> job.args["to"] |> Email.login_email(job.args["url"]) - |> Mailer.deliver_now!() + |> deliver() end :ok end + + defp deliver(email) do + with {:permanent_failure, _, _} <- Mailer.deliver_now!(email) do + {:cancel, :permanent_failure} + end + end end def send_email(type, to, url) do