Module MyApp.Email in lib is not available

I have a simple contact form that I’m trying to get to send email. I have a Sendgrid account and have followed the tutorial Sending Email. I get a warning: function MyApp.Email.contact_us_text_email/1 is undefined (module MyApp.Email is not available).

defmodule Email do
  use Bamboo.Phoenix, view: RocfDev.EmailView

  def contact_us_text_email(email) do
    |> to(
    |> from(email)
    |> subject("From Contact Us")
    |> text_body("Contact Us")

I then try to use it this way MyApp.Email.contact_us_text_email("") |> Mailer.deliver_now.

Any pointers as to how to fix this or a solution will be most appreciated. PS (I have delibrately hardcoded the email address as a quick and dirty solution. Once it works I’ll refactor).

1 Like

You have defmodule Email do. If you want it to be MyApp.Email you need defmodule MyApp.Email do