Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_mx_lookups should be a proper option #303

Open
verymilan opened this issue Jun 11, 2024 · 1 comment
Open

no_mx_lookups should be a proper option #303

verymilan opened this issue Jun 11, 2024 · 1 comment

Comments

@verymilan
Copy link

verymilan commented Jun 11, 2024

Hi there, for a deployment of ours, it is required to modify the code in order to set no_mx_lookups to true. Otherwise Keila tries to send with mailin instead of mailout. Just now we even realize that the issue reoccured again and i wonder if something changed with a recent release... having this as a proper option to configure would be quite helpful. :)

It looks like it is set tho, but maybe it does not apply to the configured sender anymore?:

$ grep -r no_mx_lookups *
grep: _build/prod/lib/gen_smtp/ebin/gen_smtp_client.beam: binary file matches
grep: _build/prod/lib/swoosh/ebin/Elixir.Swoosh.Adapters.SMTP.beam: binary file matches
_build/prod/rel/keila/releases/0.14.0/runtime.exs:            no_mx_lookups: true
_build/prod/rel/keila/releases/0.14.4/runtime.exs:            no_mx_lookups: true
_build/prod/rel/keila/releases/0.14.5/runtime.exs:            no_mx_lookups: true
_build/prod/rel/keila/releases/0.14.6/runtime.exs:            no_mx_lookups: true
_build/prod/rel/keila/releases/0.14.7/runtime.exs:            no_mx_lookups: true
grep: _build/prod/rel/keila/lib/swoosh-1.11.6/ebin/Elixir.Swoosh.Adapters.SMTP.beam: binary file matches
grep: _build/prod/rel/keila/lib/gen_smtp-1.2.0/ebin/gen_smtp_client.beam: binary file matches
config/runtime.exs:            no_mx_lookups: true
deps/swoosh/lib/swoosh/adapters/smtp.ex:        no_mx_lookups: false
deps/swoosh/lib/swoosh/adapters/smtp.ex:    no_mx_lookups: {&String.to_atom/1, [true, false]}
deps/swoosh/lib/swoosh/adapters/proton_bridge.ex:      no_mx_lookups: true
deps/gen_smtp/src/gen_smtp_client.erl:    | {no_mx_lookups, boolean()}
deps/gen_smtp/src/gen_smtp_client.erl:                case proplists:get_value(no_mx_lookups, NewOptions) of
deps/gen_smtp/src/gen_smtp_client.erl:        case proplists:get_value(no_mx_lookups, Options) of
diff --git a/config/runtime.exs b/config/runtime.exs
index 8599521..1ae181e 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -79,6 +79,7 @@ if config_env() == :prod do
           password = System.fetch_env!("MAILER_SMTP_PASSWORD")
           port = System.get_env("MAILER_SMTP_PORT", "587") |> maybe_to_int.()
           ssl? = System.get_env("MAILER_ENABLE_SSL", "FALSE") in [1, "1", "true", "TRUE"]
+

           starttls? =
             System.get_env("MAILER_ENABLE_STARTTLS", "FALSE") in [1, "1", "true", "TRUE"]
@@ -88,7 +89,8 @@ if config_env() == :prod do
             relay: host,
             username: user,
             password: password,
-            from_email: from_email
+            from_email: from_email,
+            no_mx_lookups: true
           ]
           |> put_if_not_empty.(:port, port)
           |> then(fn config ->
@verymilan
Copy link
Author

update: i was able to change it directly in smtp.ex for now:

diff --git a/lib/keila/mailings/sender_adapters/smtp.ex b/lib/keila/mailings/sender_adapters/smtp.ex
index ab4a37f..6b61b91 100644
--- a/lib/keila/mailings/sender_adapters/smtp.ex
+++ b/lib/keila/mailings/sender_adapters/smtp.ex
@@ -32,7 +32,8 @@ defmodule Keila.Mailings.SenderAdapters.SMTP do
       username: config.smtp_username,
       password: config.smtp_password,
       auth: :always,
-      port: config.smtp_port
+      port: config.smtp_port,
+      no_mx_lookups: true
     ]
     |> maybe_put_tls_opts(config)
   end

hope it wont break this time and i'd still like to mention that Keila should not lookup MX records for sending emails. if anything it should be optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant