stefannovak

stefannovak

Hi,

Likely a noob issue, apologies! I’ve been trying to migrate from a simple SendGrid Swoosh adaptor to an SMTP one, as I’ve switched over to Zoho mail. I can’t get an email to fire, but I can get it to work using a simple Python script, so I know the account setup and auth stuff is fine, I just can’t get Phoenix working with me. I’m deep in the rabbit hole of trying things I’m finding through AI or this forum and GitHub, without knowing what I’m really doing (never configured SMTP before)

I continue to get the following error, I’m using the register account email generated by phx auth.

{:error, {:retries_exceeded, {:temporary_failure, ~c"185.230.214.164", :tls_failed}}}

I’ve got this in my dev.exs

config :swoosh, :api_client, false

config :embernotes, Embernotes.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.zoho.eu",
  username: "username",
  password: "password",
  port: 587,
  ssl: false,
  tls: :always,
  auth: :always,
  tls_options: [
    verify: :verify_peer,
    versions: ["tlsv1.3"],
    cacerts: :public_key.cacerts_get(),
    depth: 99
  ]

Those tls options are things I’ve found online. Even without them I get the same issue. I hope releasing to Prod isn’t much more difficult than getting this done on dev :sweat_smile:

From the Zoho docs

SMTP Configuration settings for Zoho Mail - TLS
Outgoing Server Settings: (Personal users with an email address as username@zohomail.com and and Free Organization users):

Outgoing Server Name: smtp.zoho.eu
Port: 587
Security Type: TLS 

Require Authentication: Yes. The email address should match the email address/ email aliases of the account, for which the authentication details are provided. 

Any help or direction is appreciated. Thanks!

Showing Posts 1 to 10

ruslandoga

ruslandoga

:wave: @stefannovak

Do you get any warnings from Erlang before this :retries_exceeded error?

LostKobrakai

LostKobrakai

https://github.com/gen-smtp/gen_smtp/issues/298#issuecomment-1405328435

The options don‘t do well separating starttls from fully tls connections.

ruslandoga

ruslandoga

But Zoho seems to be “normal” STARTTLS

# doesn't work
$ openssl s_client -connect smtp.zoho.eu:587

# works
$ openssl s_client -starttls smtp -crlf -connect smtp.zoho.eu:587

So I would try this config:

config :embernotes, Embernotes.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.zoho.eu",
  username: "username",
  password: "password",
  port: 587,
  ssl: false,
  tls: :always,
  auth: :always,
  tls_options: [
    versions: [:"tlsv1.3"],
    verify: :verify_peer,
    cacerts: :public_key.cacerts_get(),
    server_name_indication: ~c"smtp.zoho.eu", # this is new
    customize_hostname_check: [ # and this is new
      match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
    ],
    depth: 99
  ]

And if it doesn’t work, maybe middlebox_comp_mode: false could be added:

config :embernotes, Embernotes.Mailer,
  adapter: Swoosh.Adapters.SMTP,
  relay: "smtp.zoho.eu",
  username: "username",
  password: "password",
  port: 587,
  ssl: false,
  tls: :always,
  auth: :always,
  tls_options: [
    versions: [:"tlsv1.3"],
    verify: :verify_peer,
    cacerts: :public_key.cacerts_get(),
    server_name_indication: ~c"smtp.zoho.eu",
    customize_hostname_check: [
      match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
    ],
    middlebox_comp_mode: false, # this is new
    depth: 99
  ]

EDIT: added customize_hostname_check

LostKobrakai

LostKobrakai

Yeah, providers do just as badly in differenciating it seems.

stefannovak

stefannovak OP

Hey guys thanks for the responses!

No Erlang error before this error, it’s just a GenServer crashing when it occurs after trying to send an email.

[error] GenServer #PID<0.1442.0> terminating
** (MatchError) no match of right hand side value: {:error, {:retries_exceeded, {:missing_requirement, ~c"185.230.214.164", :auth}}}```

EDIT: Wrong result pasted, it was the same error as in the original post.

Adding those two tls_options, server_name_indication and middlebox_comp_mode still result in the same error.

If it’s any interest, the Python setup for SMTP looked like this

# SMTP Config
smtp_server = "smtp.zoho.eu"
smtp_port = 587
smtp_user = "username"
smtp_password = "password"

try:
    with smtplib.SMTP(smtp_server, smtp_port) as server:
        server.starttls()
        server.login(smtp_user, smtp_password)
        server.send_message(msg)
        print("✅ Email sent successfully!")
except Exception as e:
    print(f"❌ Failed to send email: {e}")

I wrote that after failing to get an elixir script going, just wanted to see if any other language/framework could get it working, which made me believe it’s a Phoenix specific issue.

ruslandoga

ruslandoga

I wonder if you could try Mua adapter, in the very least it would show the actual error message: Swoosh.Adapters.Mua — Swoosh v1.26.2 (note the extra deps)

config :embernotes, Embernotes.Mailer,
  adapter: Swoosh.Adapters.Mua
  relay: "smtp.zoho.eu",
  auth: [username: "username", password: "password"],
  port: 587
D4no0

D4no0

Highly unlikely, most probably the option for authentication you are trying to use is invalid or unsupported by the server. If python allows it, have it run in debug mode so it shows the full logs that happen when talking with the server.

ruslandoga

ruslandoga

Oh, actually the new error is different, so one of the tls_options worked :slight_smile:

The error now is {:missing_requirement, ~c"185.230.214.164", :auth} and before it was {:temporary_failure, ~c"185.230.214.164", :tls_failed}, so now it’s about :username and :password options.

stefannovak

stefannovak OP

Mua worked!

But WHY haha

stefannovak

stefannovak OP

Sorry, i didn’t mean Phoenix itself, just my configuration with it

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews