【问题标题】:sending emails using sendgrid nodejs使用 sendgrid nodejs 发送电子邮件
【发布时间】:2021-10-23 11:38:48
【问题描述】:

我创建了这个 nodejs 应用程序来发送电子邮件以使用 sendgrid Api 进行营销,实际上它正在工作,但我有一个问题,我必须删除参数消息 to: 'exemple@gmail.com' 而不是仅在密件抄送收件人的电子邮件中显示它,这是代码:

require("dotenv").config();
const sgMail = require('@sendgrid/mail')
const fs = require("fs");

sgMail.setApiKey(process.env.SENDGRID_API_KEY)

const msg = {

  to: 'exemple@gmail.com',
  from: 'exemple1@gmail.com',
  bcc: ['exemple2@gmail.com','exemple3@gmail.com','exemple4@gmail.com'],
  subject: 'Sending Emails Using Sendgrid',
  html: '<p>Sending Emails Using Sendgrid</p><br><img src="cid:logo" alt="image" />',
  attachments: [{
    filename: 'img',
    type: 'image/png',
    content_id: 'logo',
    content: fs.readFileSync('imgs/img.png', { encoding: 'base64' }),
    disposition: 'inline',
  }],
};

sgMail.send(msg).then(() => {
    console.log('Email sent')
  }).catch((error) => {
    console.error(error)
});

【问题讨论】:

    标签: javascript node.js api sendgrid-api-v3 bcc


    【解决方案1】:

    查看documentation,您应该使用sendMultiple 方法而不是send 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-14
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      相关资源
      最近更新 更多