Skip to content

Commit

Permalink
Merge pull request #22 from getconversio/hotfix/rbl-error
Browse files Browse the repository at this point in the history
Handle RBL blacklist error
  • Loading branch information
stefanosala authored Jul 29, 2019
2 parents 4d38f3d + e053558 commit c140ec4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const isInvalidMailboxError = smtpReply => {
if (
smtpReply &&
/^(510|511|513|550|551|553)/.test(smtpReply) &&
!/(junk|spam|openspf|spoofing|host.+blocked)/ig.test(smtpReply)
!/(junk|spam|openspf|spoofing|host|rbl.+blocked)/ig.test(smtpReply)
) return true;

return false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "email-deep-validator",
"version": "3.2.0",
"version": "3.3.0",
"description": "Verify email address checking MX records, and SMTP connection.",
"main": "lib/index.js",
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ describe('lib/index', () => {
return self.validator.verify('bar@foo.com')
.then(({ validMailbox }) => should(validMailbox).equal(null));
});

it('returns null on spam errors-#2', () => {
const msg = '553 5.3.0 flpd575 DNSBL:RBL 521< 54.74.114.115 >_is_blocked.For assistance forward this email to abuse_rbl@abuse-att.net';
const socket = new net.Socket({ });

self.sandbox.stub(socket, 'write').callsFake(function(data) {
if (!data.includes('QUIT')) this.emit('data', msg);
});

self.connectStub.returns(socket);

setTimeout(() => socket.write('250 Foo'), 10);

return self.validator.verify('bar@foo.com')
.then(({ validMailbox }) => should(validMailbox).equal(null));
});
});

context('given no mx records', () => {
Expand Down

0 comments on commit c140ec4

Please sign in to comment.