vincentopensourcetai

vincentopensourcetai

Error when sending the confirmation email

I use Phoenix 1.7, “mix phx.gen.auth”, and set up my email with the following code.

# config/config.exs
config :hello, Hello.Mailer,
    adapter: Swoosh.Adapters.Sendgrid,
    api_key: System.get_env("SENDGRID_API_KEY")

config :swoosh, :api_client, Swoosh.ApiClient.Finch

When I register a user, I get the following error message.

[error] GenServer #PID<0.601.0> terminating
** (UndefinedFunctionError) function false.post/4 is undefined (module false is not available)
    false.post(["https://api.sendgrid.com/v3", "/mail/send"], [{"Content-Type", "application/json"}, {"User-Agent", "swoosh/1.9.1"}, {"Authorization", "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}], "{\"content\":[{\"type\":\"text/plain\",\"value\":\"\\n==============================\\n\\nHi vincent.open.source.taiwan@gmail.com,\\n\\nYou can confirm your account by visiting the URL below:\\n\\nhttp://localhost:4000/users/confirm/uejATJ8x_lsnnYTnEH7s_GMOUztU_jubWsIc4ovHeVg\\n\\nIf you didn't create an account with us, please ignore this.\\n\\n==============================\\n\"}],\"from\":{\"email\":\"service@word.today\",\"name\":\"Hello\"},\"personalizations\":[{\"to\":[{\"email\":\"vincent.open.source.taiwan@gmail.com\"}]}],\"subject\":\"Confirmation instructions\"}", %Swoosh.Email{subject: "Confirmation instructions", from: {"Hello", "service@word.today"}, to: [{"", "vincent.open.source.taiwan@gmail.com"}], cc: [], bcc: [], text_body: "\n==============================\n\nHi vincent.open.source.taiwan@gmail.com,\n\nYou can confirm your account by visiting the URL below:\n\nhttp://localhost:4000/users/confirm/uejATJ8x_lsnnYTnEH7s_GMOUztU_jubWsIc4ovHeVg\n\nIf you didn't create an account with us, please ignore this.\n\n==============================\n", html_body: nil, attachments: [], reply_to: nil, headers: %{}, private: %{}, assigns: %{}, provider_options: %{}})
    (swoosh 1.9.1) lib/swoosh/adapters/sendgrid.ex:128: Swoosh.Adapters.Sendgrid.deliver/2
    (hello 0.1.0) lib/hello/mailer.ex:2: anonymous fn/2 in Hello.Mailer.instrument/3
    (telemetry 1.2.1) /Users/vincentlin/projects/hello/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (hello 0.1.0) lib/hello/accounts/user_notifier.ex:15: Hello.Accounts.UserNotifier.deliver/3
    (hello 0.1.0) lib/hello_web/live/user_registration_live.ex:60: HelloWeb.UserRegistrationLive.handle_event/3
    (phoenix_live_view 0.18.16) lib/phoenix_live_view/channel.ex:396: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.2.1) /Users/vincentlin/projects/hello/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 0.18.16) lib/phoenix_live_view/channel.ex:216: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 4.2) gen_server.erl:1123: :gen_server.try_dispatch/4
    (stdlib 4.2) gen_server.erl:1200: :gen_server.handle_msg/6
    (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F0dIUxRFO5LYlQKD", event: "event", payload: %{"event" => "save", "type" => "form", "value" => "_csrf_token=Jx9bNy8wHDIlPwQMen0McHALCTIGdxcCwfhTNylmIkI45DXI3NBgQZXJ&user%5Bemail%5D=vincent.open.source.taiwan%40gmail.com&user%5Bpassword%5D=12345678901234567890"}, ref: "35", join_ref: "33"}
State: %{components: {%{}, %{}, 1}, join_ref: "33", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<id: "phx-F0dIUxRFO5LYlQKD", endpoint: HelloWeb.Endpoint, view: HelloWeb.UserRegistrationLive, parent_pid: nil, root_pid: #PID<0.601.0>, router: HelloWeb.Router, assigns: %{__changed__: %{}, check_errors: false, current_user: nil, flash: %{}, form: nil, live_action: :new, trigger_submit: false}, transport_pid: #PID<0.594.0>, ...>, topic: "lv:phx-F0dIUxRFO5LYlQKD", upload_names: %{}, upload_pids: %{}}

How do I solve the error?

Many thanks for your replying.

Marked As Solved

jerdew

jerdew

Could your config be set to ‘false’ in an environment specific config?

It looks like you may have config :swoosh, :api_client, false set somewhere

Also Liked

vincentopensourcetai

vincentopensourcetai

Many thanks for your reply.

I update my config as follows and it works.

# config/config.exs
config :hello, Hello.Mailer,
       adapter: Swoosh.Adapters.Sendgrid,
       api_key: System.get_env("SENDGRID_API_KEY")
# config/dev.exs
config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Hello.Finch
rio517

rio517

I ran into a loosly related issue and just wanted to document it somewhere.

(ArgumentError) unknown registry: PetalPro.Finch
 (elixir 1.14.4) lib/registry.ex:1382: Registry.key_info!/1
 (elixir 1.14.4) lib/registry.ex:580: Registry.lookup/2
 (finch 0.15.0) lib/finch/pool_manager.ex:44: Finch.PoolManager.lookup_pool/2
 (finch 0.15.0) lib/finch/pool_manager.ex:34: Finch.PoolManager.get_pool/2
 (finch 0.15.0) lib/finch.ex:284: Finch.__stream__/5
 (finch 0.15.0) lib/finch.ex:324: anonymous fn/4 in Finch.request/3
 (telemetry 1.2.1) /app/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
 (swoosh 1.9.1) lib/swoosh/api_client/finch.ex:59: Swoosh.ApiClient.Finch.post/4

The :finch_name didn’t match what was set in my application.ex supervisory tree.

Where Next?

Popular in Questions Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement