Bamboo EmailView - location problems

I’m trying to setup Bamboo to send emails when a user fills up a form asking to be contacted. My problem is that I’ve not yet full understood the relation between where the modules are placed and how they should be called.

mailer.ex and email.ex is under lib/orif/accounts/, as well as other modules.

$ head lib/orif/accounts/mailer.ex
defmodule Orif.Accounts.Mailer do                     
  use Bamboo.Mailer, otp_app: :orif
end

$ head lib/orif/accounts/email.ex
defmodule Orif.Accounts.Email do
  use Bamboo.Phoenix, view: OrifWeb.EmailView
  
  def new_contact_email(name) do

emai_view.ex is under lib/orif_web/views, as other views.

$ head lib/orif_web/views/email_view.ex                                                   
defmodule Orif.Accounts.EmailView do
  use OrifWeb, :view
end

When trying to acess the resource, the error shown is:

##### UndefinedFunctionError <small>at POST</small> <small>/contacts</small>

# function OrifWeb.Accounts.EmailView.render/2 is undefined (module OrifWeb.Accounts.EmailView is not available)

What should I correct?

Your email.ex shows the view as OrifWeb.EmailView but you’ve defined it in Orif.Accounts.EmailView

1 Like

My confusion is that the view is defined under Orif
use Bamboo.Phoenix, view: Orif.Accounts.EmailView

but the view is under orif_web directory: lib/orif_web/views/email_view.ex

1 Like