Hey guys, I’m designing a website and i need to send email to a customer.
But when i use Mailer.deliver_later/1 or deliver_now/1 i receive an error.
I don’t know where is the cause of this error.
My config.exs:
config :shopTest, ShopTest.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "smtp.gmail.com",
port: 587,
username: "****@gmail.com",
password: "*******",
tls: :if_available,
ssl: false,
retries: 1
and my module Email:
defmodule Email do
use Bamboo.Phoenix, view: ShopTest.EmailView
def welcome_text_email(email_address) do
new_email()
|> to(email_address)
|> from("********.com")
|> subject("Welcome!")
|> text_body("Welcome to MyApp!")
end
end
and my mailer.ex
defmodule ShopTest.Mailer do
use Bamboo.Mailer, otp_app: :shopTest
end
`Thank you for your help guys!
Heya, can you post the error?
@muelthe yes sorry ,
[error] Task #PID<0.418.0> started from #PID<0.415.0> terminating
** (Bamboo.SMTPAdapter.SMTPError) There was a problem sending the email through SMTP.
The error is :no_more_hosts
More detail below:
{:permanent_failure, "smtp.gmail.com", "530-5.7.0 Authentication Required. Learn more at\r\n530 5.7.0 https://support.google.com/mail/?p=WantAuthError m7sm10456280wms.0 - gsmtp\r\n"}
(bamboo_smtp 1.2.1) lib/bamboo/adapters/smtp_adapter.ex:74: Bamboo.SMTPAdapter.handle_response/1
(elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.8) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<0.19346564/0 in Bamboo.TaskSupervisorStrategy.deliver_later/3>
Args: []
It’s sending but looks like it’s being rejected by the relay service (smtp status 570) for security reasons. I’ve never used the gmail relay, but there might be a policy that requires a certain configuration e.g. the use of SSL
I found a recent’ish article here that goes into a bit more detail about using their service: How to Use the Gmail SMTP Server to Send Emails for Free