Help using bamboo config bamboo toview emails sent to development and view

trying to set up bamboo to view emails in development before using SMTP

Thanks in advance

getting
== Compilation error in file lib/bwbamb.ex ==
** (ArgumentError) could not fetch application environment Bwbamb.Bwbamb.Mailer for application :bwbamb because the application was not loaded/started. If your application depends on :bwbamb at runtime, make sure to load/start it or list it under :extra_applications in your mix.exs file
(elixir 1.10.4) lib/application.ex:653: Application.fetch_env!/2
lib/bamboo/mailer.ex:285: Bamboo.Mailer.build_config/3
lib/bwbamb.ex:36: Bwbamb.Bwbamb.Mailer.deliver_now/2
(elixir 1.10.4) lib/kernel/parallel_compiler.ex:304: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

mix.exs
defmodule Bwbamb.MixProject do
use Mix.Project

def project do
[
app: :bwbamb,
version: “0.1.0”,
elixir: “~> 1.9-rc”,
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

Run “mix help compile.app” to learn about applications.

def application do
[applications: [:bamboo],
extra_applications: [:logger]
]
end

Run “mix help deps” to learn about dependencies.

defp deps do
[
{:bamboo, “~> 1.5”}
# {:dep_from_hexpm, “~> 0.3.0”},
# {:dep_from_git, git: “https://github.com/elixir-lang/my_dep.git”, tag: “0.1.0”}
]
end
end

config.exs
Make sure you are using Bamboo.LocalAdapter in your config
config :bwbamb, Bwbamb.Mailer,
adapter: Bamboo.LocalAdapter,
open_email_in_browser_url: “http://localhost:4000/sent_emails” # optional

defmodule Bwbamb do
@moduledoc “”"
Documentation for Bwbamb.
“”"

@doc “”"
Hello world.

Examples

  iex> Bwbamb.hello()
  :world

“”"
def hello do
:world
end

some/path/within/your/app/email.ex

defmodule Bwbamb.Email do
import Bamboo.Email

def welcome_email do
new_email(
to: “john@example.com”,
from: “support@myapp.com”,
subject: “Welcome to the app.”,
html_body: “Thanks for joining!”,
text_body: “Thanks for joining!”
)
end
end

some/path/within/your/app/mailer.ex

defmodule Bwbamb.Mailer do
use Bamboo.Mailer, otp_app: :bwbamb
end

defmodule Bwbamb.SomeControllerPerhaps do
def send_welcome_email do
Email.welcome_email() # Create your email
|> Mailer.deliver_now() # Send your email
end
end

In your Router

defmodule Bwbamb.Router do
#use Phoenix.Router # or use Plug.Router if you’re not using Phoenix
use Plug.Router
if Mix.env == :dev do
# If using Phoenix
#forward “/sent_emails”, Bamboo.SentEmailViewerPlug

  # If using Plug.Router, make sure to add the `to`
  forward "/sent_emails", to: Bamboo.SentEmailViewerPlug
end

end
#defmodule Bwbamb.Mailer do

use Bamboo.Mailer, otp_app: :bwbamb

#end

end

%{to: “Tony Stark”, from: “tony.stark@example.com”}

#wbamb.Bwbamb.Router
#|> IO.inspect

Bwbamb.Bwbamb.Email.welcome_email

#Bwbamb.Bwbamb.Email.welcome_email() # Create your email
#|> Bwbamb.Bwbamb.Mailer.deliver_now() # Send your email
#|> IO.inspect
Bwbamb.Bwbamb.Email.welcome_email |> IO.inspect |> Bwbamb.Bwbamb.Mailer.deliver_now(response: true)

I think you might need to check your module names

That might be the culprit. Also, if you’ve a public repo, it would be great to debug for people trying to help you.

Thanks

config.exs file was in wrong placee (using intellij)
now getting
(CompileError) config/config.exs:2: undefined function config/3

will work on getting a public repo

Thanks again

1 Like