← blog

integration · 16 Nov 2026 · 7 min read

Why your self-hosted app's test email fails, and how to read the error it gives you

Timeouts, TLS handshake noise and 5xx replies from the relay are three different failures, and each points at a different line of your config. How to tell which one you have, what 530, 535, 550 and 554 mean in practice, and how to reproduce the failure by hand in one command.

A failed test email from a self-hosted app is one of three things. A timeout means the host blocks the port. A TLS error such as "wrong version number" means implicit TLS was used on a STARTTLS port. A reply code from the server, such as 535 5.7.8, means the connection worked and the relay refused the credentials or the message.

A node graph where a single node emits an amber beam.

You fill in five SMTP fields in the admin panel of Gitea, Ghost or Vaultwarden, press the test button, and get a red banner. The text in it rarely comes from the mail server. It comes from whichever mail library the app uses, and it describes the failure in that library’s terms: i/o timeout, wrong version number, InvalidContentType, or a bare 535.

Those strings look unrelated, but each falls into one of three groups, and the group tells you which setting to change. The first thing to work out is how far the conversation with the relay got before it broke.

Three places a test email can fail

An SMTP test passes through three stages in order. It opens a TCP connection, negotiates TLS, and only then exchanges commands, where the relay can accept or refuse.

StageWhat the app showsWhat it means
Connectiontimeout, i/o timeout, connection refusedNothing reached the relay, or nothing answered
TLSwrong version number, first record does not look like a TLS handshake, InvalidContentType, certificate errorsThe two sides disagreed about how encryption starts
ReplyA three-digit code, often with a second code such as 5.7.8The connection worked and the relay refused something

A reply code is good news of a kind. It proves the host, port and encryption are right, so you can stop editing those fields.

Timeouts and refused connections

A timeout means packets left and nothing came back. On a cloud server this is almost always the provider blocking outbound mail ports. Port 25 is blocked nearly everywhere, and some providers block 587 too. The app waits thirty seconds and reports a timeout, which does not say which side gave up.

A refused connection is different. Something answered and rejected the connection at once, which usually means the host name points somewhere with nothing listening on that port. Check the host for a typo before anything else.

Test from the machine that sends, not your laptop. For a containerised app, test from inside the container, since it may sit on a different network path from the host:

$ nc -vz -w 5 smtp.your-relay.example 587
Connection to smtp.your-relay.example 587 port [tcp/submission] succeeded!

If that hangs, no setting in the app will fix it. Use the relay’s alternative port, or its HTTP API over 443.

TLS errors almost always mean the wrong mode

These three messages come from three different libraries and describe one mistake:

SSL routines: wrong version number                         (Node.js, Ghost)
tls: first record does not look like a TLS handshake       (Go, Gitea)
received corrupt message of type InvalidContentType        (Rust, Vaultwarden)

Each one means the app opened implicit TLS, the mode used on port 465, against a port that expects to start in plain text and upgrade with STARTTLS. The relay replied with an ordinary text greeting, and the TLS library read it as a garbled handshake. The fix is the encryption setting, not the port. Choose the option your app calls starttls, smtp+starttls, or secure: false with TLS required. The port post covers why the two modes exist.

The opposite mismatch, STARTTLS against an implicit TLS port, usually shows up as a hang rather than an error, because both sides wait for the other to speak first.

Certificate errors are a separate case. certificate is valid for X, not Y means the host field holds an IP address or an alias that the certificate does not name. Use the host name the relay documents. unable to get local issuer certificate in a slim container image usually means the image has no CA bundle installed.

A related message is SMTP AUTH extension not supported by server. Most relays advertise AUTH only after STARTTLS, as RFC 3207 encourages. A client that never upgrades the connection never sees it. This is a TLS mode problem that looks like an authentication problem.

Reading the reply codes

Once the conversation reaches commands, the relay answers with a three-digit code and, on most relays, an enhanced status code after it. A first digit of 4 means try again later. A first digit of 5 means the relay will refuse the same request every time. The second code narrows down the reason. These are the replies a test email typically gets:

ReplyDefined inWhat it usually means in a test
530 5.7.0RFC 4954Authentication required. The app sent MAIL FROM without logging in. Turn authentication on
535 5.7.8RFC 4954Credentials refused. See the next section
534 5.7.9RFC 4954The relay will not accept that authentication method. Choose LOGIN or PLAIN
538 5.7.11RFC 4954Encryption required before authentication. Enable STARTTLS
550 5.7.1RFC 3463Not permitted. On a relay this is usually a sender address it will not send for
553 5.1.8RFC 3463The sender address’s domain is rejected or unknown
554 5.7.1RFC 3463Transaction refused on policy grounds. Read the text after the code
421 4.7.0RFC 5321The relay is closing the connection for now. Retry before changing anything

The text after the code matters more than the code. Relays use the same 550 5.7.1 for several different policies, and the sentence after it says which one applies. Most apps cut the reply down to the code. When that happens, reproduce the failure by hand, as shown below, to read the full line.

None of these is a bounce. A bounce concerns a recipient’s mailbox and arrives after the relay accepted the message. These replies come before acceptance, and the bounce codes post covers the other side.

When 535 means something other than a wrong password

535 5.7.8 is the reply people spend longest on, because the password looks right. Four causes account for most cases:

  1. The username is your account email. Most relays generate a separate SMTP username with the credential, and the account login is not accepted.
  2. The password was changed on the way in. In a Compose file, a $ in a value starts variable interpolation. A generated password like k8$Qe2... reaches the app as k8e2..., or with a warning about an unset variable. Write a literal dollar sign as $$, or pass the password from the environment. Trailing whitespace pasted into an admin panel does the same damage more quietly.
  3. The credential was deleted or rotated in the relay’s dashboard, and the app still holds the old one.
  4. The account is not cleared to send yet. Some relays review new accounts or domains and refuse authentication until that is done. Whether the reply text says so depends on the relay.

Reproduce it in one command

The test button hides the conversation. A manual session shows every line of it. openssl is installed nearly everywhere and speaks STARTTLS:

$ openssl s_client -starttls smtp -crlf -quiet -connect smtp.your-relay.example:587
EHLO test.local
250-smtp.your-relay.example
250-AUTH PLAIN LOGIN
250 8BITMIME

If AUTH appears in the list, the connection and TLS are fine and the problem is the credentials or the message. For a full send with authentication, swaks takes the same five values as the app and prints each reply in full:

swaks --server smtp.your-relay.example --port 587 --tls \
      --auth LOGIN --auth-user '<USER>' --auth-password '<PASS>' \
      --from app@yourdomain.com --to you@example.com

Put the password in single quotes so the shell leaves $ and ! alone. If swaks succeeds and the app fails, the difference is in how the app reads its settings: the Compose file, an admin panel value that overrides the environment, or a stale container that was never restarted.

Where Pharos fits

The Pharos relay is smtp.pharosinfra.net on port 587, or 2525 where a host blocks 587, with STARTTLS and LOGIN or PLAIN authentication. There is no implicit TLS on 465. Credentials are created per sending domain in the dashboard. Until an account or its sending domain has been reviewed, authentication fails with a reply that says so, 535 5.7.8 Account pending approval or 535 5.7.8 Sender domain pending approval, and a wrong username or password gets the plain 535. The integration pages give tested settings for Ghost, Gitea and Vaultwarden, including the exact errors each one shows when a setting is wrong.

Questions this raises

Why does the test work from my laptop but fail on the server?

Outbound port blocking is set per network. Your home connection allows port 587, and the cloud host running the container may not. Run the same test from inside the container or on the server itself, and if it times out there, switch to the relay's alternative port.

Why does my SMTP password work by hand but fail from Docker Compose?

Compose treats a dollar sign in the file as the start of a variable and replaces it, usually with nothing. A generated password containing a dollar sign reaches the app shortened, and the relay answers 535. Write each literal dollar sign as two, or pass the password in from a variable defined outside the file.

Should I switch to port 465 if 587 times out?

Only if the relay listens on 465 and you also change the encryption setting to implicit TLS, because 465 and 587 expect different handshakes. Many relays offer 2525 instead, which takes the same STARTTLS settings as 587 and is less often blocked.

Sources

Written by the Pharos team · 16 Nov 2026 rss

Check your own headers first.

If authentication is failing, Pharos fixes it as a side effect of onboarding a domain. Free plan, 3,000 emails a month.

start free