首页 > 解决方案 > i want to send email using send-grid but when i use the api_key it gives error while when i use the same api-key in previous projects it works

问题描述

i have created a new project and i want to send email on signup and password reset etc , when i used old api key it gave error **Error:

The provided authorization grant is invalid, expired, or revoked** but when i ran the older projects with same api-key it worked fine , also i tried new api-key but it is giving same error

const nodemailer = require("nodemailer")
const sTransport = require("nodemailer-sendgrid-transport")


const options = {
  auth:{
    api_key:process.env.SEND_GRID_KEY
  }
}


const mailer  = nodemailer.createTransport(sTransport(options))

router.get("/", async (req, res) => {



  let products = await productSchema.find({});
let sendmail =await  mailer.sendMail({



  to:req.user.email,
  from:process.env.FROM,
  subject:"chekcing the key",
  html:"just checking the send grid api !!"




})

标签: javascriptnode.jssendgridnodemailermern

解决方案


推荐阅读