email-smtp-verificator
v1.0.0
Published
A tool to verify an email address existence via SMTP
Downloads
27
Maintainers
Readme
Email SMTP Verificator
Based on bighappyworld's email-verify module.
Requirements
node.js >= 6.4.0
Usage
const emailSMTPVerificator = require('./email-smtp-verificator');
const verify = emailSMTPVerificator({ timeout: 12000 });
verify('[email protected]')
.then((info) => { console.log(info); })
.catch(console.log); // empty or non-string email
Callback
The callback is a function that has an info object:
{
email: string,
verified: boolean,
// error case attributes
stage: integer, // stage at which the error occurred
message: string // error message
}
Options
The options are:
{
port : integer,// port to connect with defaults to 25
sender : email, // sender address, defaults to [email protected]
timeout : integer, // socket timeout defaults to 0 which is no timeout
fqdn : domain, // used as part of the EHLO, defaults to mail.example.org
ignore: // set an ending response code integer to ignore, such as 450 for greylisted emails
}
Flow
The basic flow has following stages:
- Validate it is a proper email address.
- Get the domain of the email and grab the DNS MX records for that domain.
- Create a TCP connection to the smtp-server. Connect to the next smpt-server in MX records list if connection to the current one fails.
- Send a EHLO message.
- Send a MAIL FROM message.
- Send a RCPT TO message. The result of email verification depends on the server's response at this stage.
- Send a QUIT message. Close the connection cleanly.