I'm trying to send an email using a html email template with Bamboo (and Amazon SES) for my Phoenix/Elixir application
I've managed to get the email sending successfully using Bamboo's |> text_body(message)
method. However I now want to be able to send a html template not just a string so I'm trying to use the render
fn https://hexdocs.pm/bamboo/1.1.0/Bamboo.Phoenix.html#render/3 but I'm experiencing the following error: function MyApp.HtmlEmailView.render/2 is undefined (module MyApp.HtmlEmailView is not available)
. I get no error about my view when I use the text_body
fn.
This is my fn:
def send_test_html_email(to_email_address, subject) do
new_email()
|> from("[email protected]")
|> to(to_email_address)
|> subject(subject)
|> render("email.html")
end
and this is the example fn from the docs:
def html_email do
new_email
|> render("html_email.html")
end
I can't see any difference and as I mentioned before, the rest of the fn was working fine with text_body
as the last line instead of render
.
My expected result is that the email will send without an error. My actual result is the function MyApp.HtmlEmailView.render/2 is undefined (module MyApp.HtmlEmailView is not available)
error.
MyApp.HtmlEmailView
. Can you please double check that there is no typo in the module name, both at the call site and in the definition? – Selfemployedsend_test_html_email
function, and did you add lineuse Bamboo.Phoenix, view: MyApp.HtmlEmailView
in that module? Also, do you haveMyApp.HtmlEmailView
module? – Clifford