SpamD Network Client
This library is NodeJS driver for Spamassassin spamd protocol built over TCP. Allow check emails via Spamassassin from NodeJS.
Implemented protocol methods
- CHECK
- HEADERS
- PROCESS
- REPORT
- REPORT_IFSPAM
- SYMBOLS
- TELL
- PING
API Documentation
Api built for convenient usage in point-free style. Using native Promises.
TOC
Action.check()
Action.headers()
Action.process()
Action.report()
Action.reportIfSpam()
Action.symbols()
Connection
Connection.of
Function
Connection.of(options: SpamdClientOptions): () => Promise<Connection>
Factory for creating connection by given schema.
Parameters:
Name | Type |
---|---|
options | SpamdClientOptions |
SpamdClientOptions
Returns: () => Promise<Connection>
Example:
connect .thenAction.check'<your_email_body>' .thenconsole.log // EX: { isSpam: true, score: -0.8, threshold: 5 } .catchconsole.error // EX: Error: Cannot connect
Actions
Action.check
Function
Action.check(email: string
): (connection: Connection) => Promise<
CheckResult>
Instruct SpamAssassin to process the included message.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
CheckResult>
CheckResult
Action.headers
Function
Action.headers(email: string
): (connection: Connection) => Promise<
HeadersResult>
Instruct SpamAssassin to process the included message.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
HeadersResult>
HeadersResult
Example
Action.process
Function
Action.process(email: string
): (connection: Connection) => Promise<
ProcessResult>
Instruct SpamAssassin to process the message and return the modified message.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
ProcessReport>
ProcessResult
Example
Action.report
Function
Action.report(email: string
): (connection: Connection) => Promise<
ReportResult>
Send a request to process a message and return a report.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
ReportResult>
ReportResult
Example
Action.reportIfSpam
Function
Action.reportIfSpam(email: string
): (connection: Connection) => Promise<
ReportIfSpamResult>
Send a request to process a message and return a report only if spam detected.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
ReportIfSpamResult>
ReportIfSpamResult
Example
Produce the same that report
action described above.
Action.symbols
Function
Action.symbols(email: string
): (connection: Connection) => Promise<
SymbolsResult>
Send a request to process a message and return a report.
Parameters:
Name | Type | Description |
---|---|---|
string |
An email based on the RFC 5322 standard. |
Returns: (connection: Connection) => Promise<
SymbolsResult>
SymbolsResult
Example
License
The MIT License (MIT)
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.