I created a Phoenix app then added the bamboo module for sending email, and I successfully sent my first email using Elixir this afternoon, but I had to hard code the username and password into the config.exs
.
I read this article and set up a .env file in the root of my phoenix project, and I am trying to load the environment variables using the following statement(s), within the config.exs
file.
username: System.get_env("SMTP_USERNAME"),
password: System.get_env("SMTP_PASSWORD"),
However, the emails are not being sent, and bamboo is giving me a rather cryptic error message.
I am building the phoenix app using the following command from the terminal,
iex -S mix
and I'm manually sending the emails within a iex session with a command similar to the one below,
CrjApi.Email.hello_text_email("[email protected]") |> CrjApi.Mailer.deliver_now
but the emails are only being sent when the username / password are hard coded into the config.exs
file. How can I use the .env
file I setup so I don't have to hard code the username / password into the config.exs
?
Note: I'm running OS X, and using the fish shell.
iex
and typeSystem.get_env("SMTP_USERNAME")
, do you get the expected value? Do the same for the password. – Justin Woodnil
. And thanks for pointing me in the right direction ;) – ipatchsource .env
. – sekrett