Closed pascalwengerter closed 1 year ago
Hey, thanks for giving it a shot! The reason it can’t work like this is because of the way module attributes (@something
) work. They are set at compile time - so at a point when the env variable is not yet available.
I suggest defining a function sender_mail/1
in Keila.Auth.Emails
and instead of using System.fetch_env!/1
using Application.get_env/2
to retrieve it fom the runtime config.
I would also suggest adding a new env variable, MAILER_FROM_EMAIL
in runtime.exs
and use that explicitly instead of automatically using the SMTP user name. You can find the relevant bit in the runtime config here: https://github.com/pentacent/keila/blob/03317ad783df7ff51f542ad5168f6a820eab046c/config/runtime.exs#L41
In addition, you’d have to add config(:keila, Keila.Mailer, from_email: "hello@keila.io")
to the default config.exs
so that it will continue to work in dev
and test
:smiley:
Hey, thanks for giving it a shot! The reason it can’t work like this is because of the way module attributes (
@something
) work. They are set at compile time - so at a point when the env variable is not yet available.I suggest defining a function
sender_mail/1
inKeila.Auth.Emails
and instead of usingSystem.fetch_env!/1
usingApplication.get_env/2
to retrieve it fom the runtime config.I would also suggest adding a new env variable,
MAILER_FROM_EMAIL
inruntime.exs
and use that explicitly instead of automatically using the SMTP user name. You can find the relevant bit in the runtime config here:In addition, you’d have to add
config(:keila, Keila.Mailer, from_email: "hello@keila.io")
to the defaultconfig.exs
so that it will continue to work indev
andtest
😃
Let me see if I can come up with an acceptable solution in the upcoming days(?) ;)
@wmnnd feel free to take over here, the PR has been stale for too long and I won't be able to give it attention anytime soon :/ sry!
Adresses #48 in a naive way