Hey all, I am working on getting email authentication set up, pretty much following Passwordless Auth. Everything seems to be working great until it gets to the point where it actually grabs the template and sends the email, whence I’m getting the error:
(Phoenix.Template.UndefinedError) Could not render "magic.text" for
MyApp.EmailView, please define a matching clause for render/2 or define a template at
"web/templates/email". No templates were compiled for this module.
Here is my emailing module:
# web/emails/authentication_email.ex
defmodule MyApp.AuthenticationEmail do
@moduledoc """
Responsible for sending out our verification emails
"""
use Bamboo.Phoenix, view: MyApp.EmailView
import Bamboo.Email
@doc """
The sign in email containing the magic link.
"""
def magic_link(token_value, user) do
new_email()
|> to(user.email)
|> from("info@MyApp.com")
|> subject("Your magic link")
|> assign(:token, token_value)
|> render("magic.text")
end
end
Here is my view:
defmodule MyApp.EmailView do
use MyApp.Web, :view
end
And my template, which is located at web/templates/email/magic.text
Here is your login link:
<%= signin_url(MyApp.Endpoint, :show, @token) %>
It is valid for one hour.
Everything here looks good to me, and the error and trace indicate it’s looking where the template is, so I am kind of out of ideas since the template is there… Any ideas?