can someone suggest the solution: I am trying to setup self-hosted email service, but could not.

config part

PROTOCOL       = smtp+starttls
SMTP_ADDR      = unknown.domain
SMTP_PORT      = 587
ENABLED        = true   
FROM           = name@unknown.domain
MAILER_TYPE    = smtp           
IS_TLS_ENABLED = true              
USER           = name@unknown.domain
PASSWD = strongpassword

Both email server and gitea are running from 1 docker compose.

Email server ports are forwarded to the world. I could not connect neither via docker compose network (certificate problem), nor via globally visible domain. I am testing via in browser gitea admin settings widget designated to send test email. And, in the last case (trying to connect via globally visible name, but it’s wrong - I should connect via local network to save time) I got

Failed to send a testing email to "": gomail: could not send email 1: failed to establish network connection to SMTP server: dial tcp connect: connection refused

As a solution, add to container /etc/hosts proepr real IP of email service, but to make it works locally I need another solution.

May be firewall issue, sounds similar to this recent post SSH connection refused - #4 by alexhopeoconnor