requireTls plugin enforces transport layer security by rejecting MAIL FROM commands on unencrypted connections. This ensures that email transmission occurs over secure, encrypted channels.
What It Does
The requireTls plugin:- Checks if the connection is encrypted when MAIL FROM is received
- Rejects the command if the connection is not secure
- Returns the RFC 3207 standard 530 error code for unencrypted attempts
- Works in conjunction with STARTTLS to enforce encryption
Function Signature
requireTls function takes no parameters and returns a Fumi plugin.
Usage
Import and use the requireTls plugin in your Fumi application:How It Works
The plugin works with STARTTLS:- Client connects to the server (unencrypted)
- Server advertises STARTTLS capability
- Client must issue STARTTLS command to upgrade to encrypted connection
- If client tries MAIL FROM without upgrading, the plugin rejects it
- If client has upgraded, the mail transaction proceeds normally
Error Response
When a client attempts MAIL FROM on an unencrypted connection:Implementation
ctx.session.secure which is true if the connection has been upgraded via STARTTLS or was initially TLS-encrypted.
Middleware vs Protocol-Level EnforcementThis plugin provides middleware-level TLS enforcement at the MAIL FROM stage. For protocol-level enforcement that requires TLS before any commands are accepted, set The middleware approach allows clients to connect and see capabilities before being required to upgrade.
requireTLS: true in FumiOptions instead:Use Cases
- Privacy: Ensure email content is encrypted in transit
- Compliance: Meet security requirements for handling sensitive data
- Security: Prevent credential theft and man-in-the-middle attacks
- Best Practices: Follow modern email security standards
Related
- Learn about TLS & Security configuration
- See Fumi class API for server setup