Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Send Email sgMail

router.post(
    '/send-mail',
    AuthController.sendMail
)




async sendMail(req, res, next){

        try{
        let otp = generateOtp();

        const msg = {
            to: req.body.email,
            from: 'baldianupamdev@yopmail.com', // Change to your verified sender
            subject: 'Eye 1-1: Verify Your Login',
            text: 'Please enter the following OTP to verify your login : ' + otp,
            html: '<strong>Please enter the following OTP to verify your login :' + otp + ' </strong>',
        }

        //Send Email Here
        sgMail
            .send(msg)
            .then(() => {
                console.log('Email sent');
                return res.success({
                }, "Email Send Successfully"
                );

                // const userJson = user.toJSON();
                // ['password', 'authTokenIssuedAt', 'otp', 'emailToken', '__v'].forEach(key => delete userJson[key]);
                // userJson.isDefaultLocation = false;
                // return res.success({
                //     "language": req.headers['accept-language'],
                //     token,
                //     user: userJson,
                // }, "Registration Completed"
                // );

            })}
            catch (err) {
                console.log(err);
                return next(err)
            }
        }

Comment

PREVIOUS NEXT
Code Example
Javascript :: createelement with id 
Javascript :: javascript count up timer 
Javascript :: toggle password hide show 
Javascript :: normalize js 
Javascript :: manually set jquery text box 
Javascript :: does pycharm support javascript 
Javascript :: Discord.js Get A Bot To Join A Music Chanel 
Javascript :: functions in javascript 
Javascript :: how to do an isogram in javascript 
Javascript :: js array contains 
Javascript :: change version webpack-dev-middleware 
Javascript :: use localstorage hook 
Javascript :: react if statement 
Javascript :: classlist.contain in javascript 
Javascript :: puppeteer js headless mode 
Javascript :: delete item from array 
Javascript :: new date getday js 
Javascript :: JavaScript throw with try...catch 
Javascript :: print string multiple times in javascript 
Javascript :: ismobile react 
Javascript :: vue component lifecycle 
Javascript :: js how to see console day tomorrow 
Javascript :: jest mock method by name 
Javascript :: javascript for...of with Strings 
Javascript :: math captcha 
Javascript :: video conferencing app with html and js 
Javascript :: then and catch in promise 
Javascript :: javascript add to home screen button 
Javascript :: react 17 
Javascript :: javascript training 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =