Bamboo argument error in Production(heroku)

Hi guys! I need your help.
In my development environment, sending email using Bamboo(Mailgun adapter) is working fine.
But in my production, I got error like below.

** (ArgumentError) argument error                                                                                                                            
(bamboo 1.5.0) lib/bamboo/adapters/mailgun_adapter.ex:120: Bamboo.MailgunAdapter.full_uri/1                                                                  
(bamboo 1.5.0) lib/bamboo/adapters/mailgun_adapter.ex:100: Bamboo.MailgunAdapter.deliver/2                                                                   
(elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2                                                                                      
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3                                                                                                  
Function: #Function<0.1924921/0 in Bamboo.TaskSupervisorStrategy.deliver_later/3>                                                                            
Args: []

I double checked to config vars name and value.

in config.exs

config :my_app, MyApp.Emails.Mailer,
  adapter: Bamboo.MailgunAdapter,
  api_key: System.get_env("MAILGUN_API"),
  domain: System.get_env("MAILGUN_DOMAIN_NAME"),
  base_uri: System.get_env("MAILGUN_BASE_URI")

I don’t know why this is happening…
Because args are empty? I can see Args: [] in log.
So maybe not passing any config value correctly?(api key, domain name, base uri)?
I tested in Production iex session
System.get_env("MAILGUN_API") it returns correct value. hmmm

Email.contact_admin("category", "John", "john@gmail.com", "hi my friend")
 |> Mailer.deliver_now(config: %{api_key: "api_key", domain: "domain name", base_uri: "https://api.mailgun.net/v3"})

I tried this in Production iex session and it works!.
So What am I missing? Any idea?

That’s extremely suspicious that you are using the environment variables on your development host (which are probably no set at all) in production.

The config.exs and its cousins (except the releases.exs) are evaluated at build-time, so either set those env vars before building the prod version, or put those configuration into the releases.exs.

1 Like

I found an answer.
MyApp.Emails.Email and MyApp.Emails.Mailer must be MyApp.Email and MyApp.Mailer