smtp-channel
Advanced tools
Comparing version
{ | ||
"name": "smtp-channel", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Low level SMTP communication layer.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -99,3 +99,3 @@  [](https://badge.fury.io/js/smtp-channel) [](https://gemnasium.com/xpepermint/smtp-channel) | ||
| data | String,Stream,Buffer | Yes | - | Data to be sent to the SMTP server. Make sure that you apply to the SMTP rules and complete lines with `\r\n`. When sending email data stream, make sure you include the `.` as the last line. | ||
| handler | Function|Promise | No | - | A method for handling SMTP server replies. | ||
| handler | Function,Promise | No | - | A method for handling SMTP server replies. | ||
| timeout | Integer | No | 0 | A time in milliseconds after the operation automatically rejects (`0` disables the timeout). | ||
@@ -131,2 +131,12 @@ | ||
**Event: reply**: (line, {code, isLast}) => {} | ||
> Emitted when a new reply from the server is received. | ||
| Argument | Type | Description | ||
|----------|------|------------ | ||
| line | String | SMTP server reply string. | ||
| code | String | SMTP server reply code. | ||
| isLast | Boolean | Is `true` when the `line` represents the last reply from the SMTP server. | ||
**Event: timeout**: () => {} | ||
@@ -133,0 +143,0 @@ |
@@ -101,3 +101,3 @@ const net = require('net'); | ||
parseReplyCode(line) { | ||
return line.substr(0, 3); | ||
return line ? line.substr(0, 3) : null; | ||
} | ||
@@ -114,3 +114,3 @@ | ||
isLastReply(line) { | ||
return line.charAt(3) === ' '; | ||
return line ? line.charAt(3) === ' ' : null; | ||
} | ||
@@ -254,5 +254,6 @@ | ||
Promise.resolve(line, {code, isLast}) | ||
Promise.resolve() | ||
.then(() => {if (handler) handler(line, args)}) | ||
.then(() => {if (isLast) resolve(code)}); | ||
.then(() => {if (isLast) resolve(code)}) | ||
.catch(reject); | ||
@@ -259,0 +260,0 @@ if (isLast) { |
19293
2.02%351
0.29%167
6.37%