
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
smtpd-lite
Advanced tools
An uncomplicated SMTP mail receiver for Node.js.
var Server = require('smtpd-lite');
var server = new Server({
host: 'mail.example.com',
domain: 'example.com'
});
server.on('receive', function(mail) {
console.log(mail);
});
server.listen(25);
# Install with npm
$ npm install smtpd-lite
# Install from source code
$ git clone https://github.com/g6123/node-smtpd-lite.git smtpd-lite
smtpd-lite
uses new stream API (stream2), and is supported for Node.js v0.10+.libicu
. Install guide is here.This class inherits net.Server. You can use all methods and events from net.Server such as server.listen()
, server.close()
, server.on('error', function(error) { ... })
, etc.
options
defines all settings for server and supoorts following properties :
false
, all TLS features are disabled. (default : false)
false
, all authentication features are disabled. (default : false)
false
, log file won't be created. (default : false)Removes temporary files in the directory configured by config['tempDir']
. If all
argument is given true
, it removes all files in the directory. Otherwise, it removes only empty (zero-size) files.
Alias for sessionStart event of Receiver.
Alias for sessionEnd event of Receiver.
Alias for parseStart event of Parser.
Alias for parseEnd event of Parser.
Another alias for parseEnd event of Parser.
Replaces the socket which the receiver uses. Also it removes, from the old socket, event listeners registered by receiver, and sets the same listeners on the new socket.
The socket a receiver is currently using.
Indicates whether or not HELO/EHLO message response was sent.
There are four possible states.
-1
means that TLS features are disabled.0
means TLS features are enabled, but the socket is not secure due to failed negotiation or just because TLS negotiation has not yet started.1
means the socket is secured with TLS.2
means that server is negotiating with the client.There are four possible states.
-1
means authentication is disabled.0
means authentication feature is enabled, but the client has not yet logged in or the authentication has failed.1
means the client has been authenticated successfully.2
means authentication is in the progress.Emitted when the server was connected to a new client or the client made a new session (RSET
or the end of DATA
.)
Emitted when the client sends AUTH
command. Until callback
is called, all data chunks from the client is processed only by event listener listening on this auth event. When callback
is called with error
, the receiver will consider the authentication has failed. Below is an example code.
var Server = require('smtpd-lite');
var server = new Server({
auth: {
force: false,
type: ['DIGEST-MD5', 'CRAM-MD5']
}
});
server.on('sessionStart', function(receiver) {
receiver.on('auth', function(data, callback) {
// Authenticate the client with the given `data`..
if(error) {
receiver.socket.send(error + 'Authentication failed');
} else {
receiver.socket.send('235 Authentication successful');
}
callback(error);
});
});
Emitted when the server reached the end of a mail or the client made new session (RSET
or the end of DATA
.) Not emitted when the connection has been closed or session been reset before any mail had been received.
This class inherits stream.Transform. You can use all methods and events from stream.Transform such as parser.pipe()
, parser.end()
, parser.on('error', function(error) { ... })
, etc.
Emitted when the first line to be parsed is received.
mail
argument is an object with following properties :
{
id: String,
header: { ... },
body: {
stream: stream.Readable stream,
length: Number
},
multiparts: [
{
header: { ... },
stream: stream.Readable stream,
length: Number
}, ...
]
}
stream
.stream
.FAQs
An uncomplicated SMTP server for Node.js
We found that smtpd-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.