MatOsinski

MatOsinski

Bamboo issue - no emails sent error

Hi guys! I have created a system, which will be sent info to the user’s mail (everything locally). However, I am getting this type of error

Path which I am using http://localhost:4000/dev/mailbox

I have added this to my config/configs.exs

config :rewardapp, Rewardapp.Mailer,
  adapter: Bamboo.LocalAdapter

My mailer.ex

defmodule Rewardapp.Email do
  import Bamboo.Email
  import Bamboo.Phoenix

  def rewardEmail(user) do
    base_email()
    |> to(user)
    |> subject("You were granted points!")
    |> text_body("You were granted some points! To check, log into your account!")
  end

  defp base_email() do
    new_email()
    |> from("rewardapp@gmail.com") # Set a default from
  end
end

This is the IO.inspect of my function

function:

Rewardapp.Email.rewardEmail(userEmail)
IO.inspect(Rewardapp.Email.rewardEmail(userEmail))

result:

%Bamboo.Email{
  assigns: %{},
  attachments: [],
  bcc: nil,
  cc: nil,
  from: "rewardapp@gmail.com",
  headers: %{},
  html_body: nil,
  private: %{},
  subject: "You were granted points!",
  text_body: "You were granted some points! To check, log into your account!",
  to: "kamig@gmail.com"
}

I am using bamboo v.1.5.

In my router.ex I have configured the path:

  if Mix.env() == :dev do
    scope "/dev" do
      pipe_through :browser

      #forward "/mailbox", Plug.Swoosh.MailboxPreview
      forward "/mailbox", Bamboo.SentEmailViewerPlug
    end
  end

Why am I not able to see the output in the directory localhost:4000/dev/mailbox?

Most Liked

pmangalakader

pmangalakader

You are missing this part:

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

Kindly check the official documentation here: GitHub - beam-community/bamboo at master · GitHub

You have to use your Application Mailer module to deliver the emails.

In your case, try to import this on top of the Rewardapp.Email:

import Rewardapp.Mailer
....
...
# in your email fn:
def rewardEmail(user) do
    base_email()
    |> to(user)
    |> subject("You were granted points!")
    |> text_body("You were granted some points! To check, log into your account!")
    |> Mailer.deliver_now!() # to deliver immediately
  end
pmangalakader

pmangalakader

@MatOsinski Kindly look at this video here: https://www.youtube.com/watch?v=tHfGXnrvksQ

That kind of gives the step by step instructions on how to use Bamboo. Hope this helps!

Also this link: Using Bamboo to Send Emails in Phoenix - DEV Community

MatOsinski

MatOsinski

Hi @pmangalakader. I have managed to make it work. There was error with Bamboo module name. However, I do really appreciate your help!!!

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement