peter-de-boer

peter-de-boer

Network failure using Swoosh

I am trying to use swoosh for emailing. I have basically followed the steps in Swoosh.Mailer — Swoosh v1.26.2.

My config looks like:

config :bw, Bw.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.gmail.com",
  username: System.get_env("BW_MAIL_USERNAME"), # gmail username
  password: System.get_env("BW_MAIL_PASSWORD"), # gmail password
  ssl: true,
  tls: :always,
  auth: :always,
  port: 1025,
  retries: 2,
  no_mx_lookups: false

I have created an email struct, but when I try to deliver it, I get:

> Bw.Mailer.deliver(email)
{:error, {:retries_exceeded, {:network_failure, '108.177.126.109', {:error, :timeout}}}}

I have no idea where the error could be. Is it in my configuration? Any help is appreciated.

Marked As Solved

derek-zhou

derek-zhou

You sure the port 1025 is correct? Usually SMTP with STARTTLS is on port 587, ans SSL SMTP is on 465.

Also, Gmail SMTP is supposed to be used by interactive clients, not a backend server. They may have some rule based filtering and limiting that hinder your usage. I 'd stick to one of the following:

  • Sendgrid, etc, 100 mails per day in the free tier
  • Amazon SES. If you are sending a lot
  • Your own SMTP server

Also Liked

ndan

ndan

Working settings for Gmail (port 587)

config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.gmail.com",
  username: "name@gmail.com",
  password: "apppassword",
  ssl: false,
  tls: :always,
  auth: :always,
  port: 587,
  retries: 2

Requirements for Gmail:

  1. Set up 2-Step Verification
  2. Generate app password
  3. Switch off your VPN (if you’re testing on localhost)

Last Post!

ndan

ndan

Working settings for Gmail (port 587)

config :sample, Sample.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.gmail.com",
  username: "name@gmail.com",
  password: "apppassword",
  ssl: false,
  tls: :always,
  auth: :always,
  port: 587,
  retries: 2

Requirements for Gmail:

  1. Set up 2-Step Verification
  2. Generate app password
  3. Switch off your VPN (if you’re testing on localhost)

Where Next?

Popular in Questions Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement