nodemailer gives type error: this.transporter.send is not a function

const nodemailer = require('nodemailer');
const smtpTransport = require('nodemailer-smtp-transport');
const xoauth2 = require('xoauth2');
const mailTransport = nodemailer.createTransport(smtpTransport,{
    service: 'Gmail',
    auth:{
            xoauth2: xoauth2.createXOAuth2Generator({
            user:credentials.gmail.user,
            pass:credentials.gmail.password,
        })
    }
});

I want it to send the mail once the form has been successfully submitted
hence my code;

 mailTransport.sendMail({
            from:'"createTops" ',
            to:credentials.gmail.user,
            subject:'successful completion of form',
            text:'thank you for signing up enjoy createTops.com'
        }, function(err){
            if(err){
                console.error('unable to send email: '+error);
            };
        });

i get this error

TypeError: this.transporter.send is not a function
at _processPlugins.err (C:desktopexpressnode_modulesnodemailerlibmailerindex.js:214:34)....

Leave a Reply

Your email address will not be published. Required fields are marked *