A
A
Alexander2021-01-17 21:04:32
Node.js
Alexander, 2021-01-17 21:04:32

Email validators for discord.js bot?

I am writing a bot for auto sending letters from discord to any mail. But the problem is its validation. Tried through the module , but this validator does not give any results and has only a function: . And after that, nowhere is it explained how to display the result. The code for sending the email:const validator = require("email-validator")validator.validate(`${usermail}`)

const data = require('./secure.json');
const nodemailer = require('nodemailer');

const botmail = data.mail;
const botpass = data.pass;
let usermail = args[0];
let textmail = args.slice(1).join(' ') || 'error~';
let transporter = nodemailer.createTransport({
     service: 'gmail',
     secure: true,
     auth: {
            user: `${botmail}`,
            pass: `${botpass}`
     }
});
transporter.sendMail({
       from: `"Discord Message Relay" ${botmail}`,
       to: `${usermail}, ${usermail}`,
       text: `${textmail}`
});

If anyone needs it, I use nodemailer to send emails

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-01-19
@BigTooth

if (!validator.validate("[email protected]")) return ... ;

A
Anton Shamanov, 2021-01-17
@SilenceOfWinter

И после этого нигде не объясняется каким образом вывести результат

what result are we talking about? validator.validate() returns a boolean, is that enough and why wrap variables?
`${usermail}`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question