sendmail milter protocol javscript client library
help you write a sendmail/postfix milter in javascript
var milterjs = require('milterjs');
milterjs.on('helo', function(ctx) {
console.log('helo event !');
ctx.continue();
});
milterjs.listen(9568, '127.0.0.1');
Call a function on a specified event.
- eventName: The name of the event.
- listener: The callback function called on event previously specified.
Start listening for sendmail/postfix connections on the given port and host.
- port: number of port
- host: ipv4 or ipv6 string address, default is
0.0.0.0
EventName | Parameters | accept/reject Action | Description |
---|---|---|---|
abort | ctx | no | cancel current message and get ready to process a new one. |
body | ctx, BodyChunk | yes | Body chunk (up to MILTER_CHUNK_SIZE (65535) bytes.) |
connect | ctx, hostname, connection_type, address, port | yes | SMTP connection information. |
eom | ctx | yes | the end of the body. |
helo | ctx, heloName | yes | HELO/EHLO name |
envfrom | ctx, sender | yes | array[0] sender, with <> qualification. array[1] and beyond are ESMTP arguments, if any. |
header | ctx, header | no | array[0] header, array[1] value |
eoh | ctx | yes | the end of headers. |
envrcpt | ctx, recipient | yes | array[0] recipient, with <> qualification. array[1] and beyond are ESMTP arguments, if any. |
data | ctx | yes | end of data. |
close | ctx | no | close milter connection. |
unknown | ctx, command | no | tell the milter that an unknown smtp command has been received. |
error | error | no | an error has occur. |
ctx is the Milter context object.
version
: the milter protocol version of MTA.macros
: object containing all macros.uniqueID
: unique identifier for milter connection.
This will skip to the end of the milter sequence, and recycle back to the state before SMFIC_MAIL. The MTA may, instead, close the connection at that point.
If issued at the end of the milter conversation, functions the same as accept()
.
Note that message processing MAY continue afterwards, but the mail will
not be delivered even if accepted with accept()
.
code
: string with length of 3 characters. seemessage
: string
This is an asynchronous response which is sent to the MTA to reset the communications timer during long operations. The MTA should consume as many of these responses as are sent, waiting for the real response for the issued command.
reason
: string This quarantines the message into a holding pool defined by the MTA.
header
: stringvalue
: string
rcpt
: string email of new recipient
header
: stringnum
: number (integer value)value
: string Change thenum
'th header of nameheader
to the valuevalue
rcpt
: string
chunk
: string Replace the message body with thechunk
. This method may be called multiple times, each call appending to the replacement buffer. End-of-line should be represented by CR-LF ("\r\n").
This method provides an implementation to access the mlfi_setsender method added to the libmilter library as part of the mlfi-setsender project