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
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 - thoughtbot/bamboo at master
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
@MatOsinski Kindly look at this video here: Sending Email in Elixir with Bamboo Part 1 - YouTube
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
Hi @pmangalakader. I have managed to make it work. There was error with Bamboo module name. However, I do really appreciate your help!!!









