Complete example
lmtp-server.ts
How LMTP differs from SMTP
1
LHLO instead of EHLO
Clients greet the server with
LHLO instead of EHLO or HELO.2
Per-recipient responses
After the DATA phase, the server sends one response line for each RCPT TO command, in the same order.
3
No pipelining
LMTP does not support command pipelining.
4
Local delivery focus
LMTP is designed for local mail delivery, not relaying between domains.
Per-recipient responses
In LMTP mode, theonData callback’s second argument can be an array:
- A string for success (generates a 250 response)
- An SMTPError object with a
responseCodeproperty
Creating error responses
Helper function to create typed errors:LMTP response codes
Common LMTP response codes:Example LMTP dialogue
Here’s what a complete LMTP session looks like:Testing the LMTP server
Create test mailboxes:Validating recipients early
You can still reject recipients during the RCPT TO phase if you want to avoid partial delivery:However, some LMTP use cases prefer to accept all recipients during RCPT TO and return per-recipient errors during DATA. This allows logging all attempted recipients.
Use cases for LMTP
LMTP is commonly used for:- Mail delivery agents (MDAs): Delivering mail to local mailboxes
- Mailing list servers: Expanding a single message to multiple recipients
- Spam filters: Per-recipient filtering decisions
- Local mail routing: Between components in a mail system
Next steps
Callbacks reference
Learn about onData and per-recipient responses
Configuration
Explore all LMTP configuration options
Basic server
Start with a basic SMTP server
Session object
Understand the session envelope