how to send message via node mailer

I attempted to integrate node mailer on my local env.
but I can’t send message via node mailer. I just used source code same as github.

let transporter = nodemailer.createTransport({
    service: 'gmail',
      auth: {
        type: 'OAuth2',
        user: process.env.MAIL_USERNAME,
        pass: process.env.MAIL_PASSWORD,
        clientId: process.env.OAUTH_CLIENTID,
        clientSecret: process.env.OAUTH_CLIENT_SECRET,
        refreshToken: process.env.OAUTH_REFRESH_TOKEN
    }
});

I’d like to know the reason why couldn’t send message via node mailer.

I just wanted to send message to other mail.

>Solution :

Perhaps the reason is that you tried it on your local environment.
Deploy the project to the hosting server and try it out. It looks like it will work
out. Good luck.

Leave a Reply