node-email-verificator
v0.1.3
Published
A simple way of email confirmation by sending a confirmation code to the client for verificatiion
Downloads
11
Maintainers
Readme
Node Email Verificator
NEV is a simplified method of sending quick verification code to email for verification.
NEV Functions
- config
- send
- verify
config
nev.config(service, user, pass);
The config function takes 3 parameters:
- service: The host for sending mail (e.g gmail, yahoo)
- user: Users email (e.g [email protected])
- pass: The users password (e.g passw0rd)
If you are using gmail, you have to allow Less Secure App
send
When a post request for verification is made, the send function delivers the confirmation code to the email parameter
nev.send(email);
The send function takes a parameters:
- email: The client's email
verify
When a post request for confirmation is made, the verify function confirms the confirmation code from the client
nev.verify(code);
The send function takes a parameters:
- code: The confirmation code from the client
Example with express
const express = require('express');
const nev = require('node-email-verificator');
const server = express();
nev.config('gmail', '[email protected]', 'passw0rde');
server.post('/', (req, res) => {
nev.send('[email protected]');
res.sendFile('./confirm.html');
})
server.post('/confirm', (req, res) => {
let code = req.body.code;
if(nev.verify(code)){ //if successful
res.sendFile('./success.html')
}else{ // if error
res.sendFile('./index.html', {message: 'Please Try Again'})
}
})
server.listen(3000, () => console.log('Using NEV on port 3000'))
Contribution
Contribute on github Here