-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathbounce-test.js
151 lines (124 loc) · 7.22 KB
/
bounce-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
'use strict';
const test = require('node:test');
const assert = require('node:assert').strict;
const { bounceDetect } = require('../lib/bounce-detect');
const fs = require('fs');
const Path = require('path');
const path = fname => Path.join(__dirname, 'fixtures', 'bounces', fname);
test('Bounce parsing tests', async t => {
await t.test('163', async () => {
const content = await fs.promises.readFile(path('163.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, 'SMTP error, RCPT TO: Host ethereal.email(54.36.85.113) RCPT TO said 550 No such user here');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('fastmail', async () => {
const content = await fs.promises.readFile(path('fastmail.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, '550 No such user here');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('gmail', async () => {
const content = await fs.promises.readFile(path('gmail.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table'
);
assert.strictEqual(bounce.messageId, '<CAPacwgw3pCyVcmW4nVy8VPX5u5ksn_wZB2jZ_tLUM2es7LaiEA@mail.gmail.com>');
});
await t.test('hotmail', async () => {
const content = await fs.promises.readFile(path('hotmail.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table'
);
assert.strictEqual(bounce.messageId, '<DB6PR0902MB194406730EDCF3E12EE16DCF90209@DB6PR0902MB1944.eurprd09.prod.outlook.com>');
});
await t.test('mailru', async () => {
const content = await fs.promises.readFile(path('mailru.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, '550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('outlook', async () => {
const content = await fs.promises.readFile(path('outlook.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table'
);
assert.strictEqual(bounce.messageId, '<PR1PR07MB57558E5D11D6C2BA6F950391D7209@PR1PR07MB5755.eurprd07.prod.outlook.com>');
});
await t.test('postfix', async () => {
const content = await fs.promises.readFile(path('postfix.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, '550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table');
assert.strictEqual(bounce.queueId, 'DF59B82305');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('rambler', async () => {
const content = await fs.promises.readFile(path('rambler.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, '550 No such user here');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('workmail', async () => {
const content = await fs.promises.readFile(path('workmail.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table'
);
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('Yahoo', async () => {
const content = await fs.promises.readFile(path('yahoo.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'550: 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table'
);
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('zonemta', async () => {
const content = await fs.promises.readFile(path('zonemta.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(bounce.response.message, '550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table');
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
await t.test('zoho', async () => {
const content = await fs.promises.readFile(path('zoho.eml'));
const bounce = await bounceDetect(content);
assert.strictEqual(bounce.recipient, '[email protected]');
assert.strictEqual(bounce.action, 'failed');
assert.strictEqual(
bounce.response.message,
'5.2.1 The email account that you tried to reach is disabled. Learn more at 5.2.1 https://support.google.com/mail/?p=DisabledUser j8-20020a170903024800b001946612570csi19333477plh.316 - gsmtp'
);
assert.strictEqual(bounce.messageId, '<[email protected]>');
});
});