Testing Odoo outgoing e-mail without a real mail server
Settings > Technical > Outgoing Mail Servers has a Test Connection button. When it answers "No response received. Check server address and port number." after about 25 seconds, the credentials were never tried: the TCP connection did not complete.
1. Is it the port or the account?
Probe the port from the machine that runs Odoo, and compare with a host you know works. A timeout and an immediate refusal mean different things.
import socket
for host, port in [("smtp.example.org", 25), ("smtp.gmail.com", 25), ("smtp.gmail.com", 587)]:
s = socket.socket(); s.settimeout(8)
try:
s.connect((host, port)); print(host, port, "open", s.recv(80)[:60])
except Exception as e:
print(host, port, type(e).__name__)
finally:
s.close()
| Result | Meaning |
|---|---|
TimeoutError on 25, but 587 connects | Your network drops outbound port 25. Many ISPs do. Not an Odoo or credentials problem. |
ConnectionRefusedError (fast, ~0.2 s) | The host answered and nothing listens on that port. Use the port the provider documents. |
| Connects, banner shown, Odoo still fails | Now check encryption (none / STARTTLS / SSL) and the login. |
2. Capture mail locally instead
To check what a template looks like you do not need delivery at all. Run a sink that accepts any message and writes it to disk:
python3 smtp_sink.py 1025 mail-sink
Source: smtp_sink.py.
It uses only the standard library, handles the dot-stuffing of the SMTP DATA command, and
ignores a client that hangs up early (a port probe, for example).
Then edit the outgoing mail server in Odoo:
| SMTP Server | 127.0.0.1 |
|---|---|
| SMTP Port | 1025 |
| Connection Security | None |
| Authentication | none needed (leave user and password empty) |
| From Filter | empty |
Each message lands as mail-sink/0001-recipient.eml. Open it in a mail client, or read the
HTML part in a browser.
3. "Sent" in the UI is not "delivered"
An action that queues mail (mail.mail with a cron) returns success at once. The real result
is the state and failure_reason of the mail.mail record and the
Odoo log. A custom log row that says sent may only mean "queued". When a button seems to do
nothing, look there first:
select id, state, left(failure_reason, 120) from mail_mail order by id desc limit 5;
One failure I hit this way came from the provider, not from Odoo:
SMTPDataError (500, ... Failed to send mail No balance). A temporary mailbox service had a
send quota, and a script using smtplib directly got the same error, which ruled Odoo out.
4. A real server for staging: Lark Mail
If a staging environment needs real delivery, Lark Mail can be used as an SMTP server for an address on a domain you control. From Lark's documentation:
- Outgoing server:
smtp.larksuite.com, SSL, port465. - A separate password for third-party clients is generated in the Lark desktop app (Settings > Email > Third-party email client login). The mobile app and the web version cannot generate it.
- An administrator must switch the third-party client permission on first (Admin Console > Product Settings > Mail > Email Management Tools > User Function Permissions).
- The account needs a business e-mail address assigned on a verified domain, or Lark shows No email address.
Set the Odoo From Filter and the mail.default.from system parameter to that same
address, so the sender matches the login.