erlangelixirphoenix-frameworkflyresend.com

Error phoenix app sending Email on fly.io with Resend


I am building my company’s website, so I decided to use Resend for mailing.

Locally. All works fine, but when I put my website on production, the Resend API doesn’t work, and sentry shows me the error below.

mi config is: elixir Version:1.15.4 (compiled with Erlang/OTP 26) Phoenix: 1.7.7 resend: 0.4

no match of right-hand side value: {: error, :enoent}

pubkey_os_cacerts.erl in :pubkey_os_cacerts.get/0 at line 38 httpc.erl in :httpc.ssl_verify_host_options/1 at line 476 httpc.erl in anonymous fn/0 in :httpc.http_options_default/0 at line 1015 httpc.erl in :httpc.http_options/3 at line 961 httpc.erl in :httpc.handle_request/9 at line 771 lib/tesla/adapter/httpc.ex in Tesla.Adapter.Httpc.request/2 at line 52 lib/tesla/adapter/httpc.ex in Tesla.Adapter.Httpc.call/2 at line 22 lib/tesla/middleware/json.ex in Tesla.Middleware.JSON.call/3 at line 54

I need to send a email, locally works and change from swoosh to a simple Resend apis with POST method but locally continue working and in production continue failing


Solution

  • Judging by this issue reported on the otp, and from what the error message says, your production machine is missing its root cert file. The error is described here in the OTP documentation.

    Returns the trusted CA certificates if any are loaded, otherwise uses cacerts_load/0 to load them. The function fails if no cacerts could be loaded.

    You need to install a CA certificate on the machine.