简体   繁体   English

使用 sendgrid nodejs 发送电子邮件

[英]sending emails using sendgrid nodejs

i create this nodejs app to send emails for marcketing using sendgrid Api, in fact it's working but i have a problem that i have to remove param message to: 'exemple@gmail.com' and not display it in the email just the bcc recipients, this is the code:我创建此 nodejs 应用程序以使用 sendgrid Api 发送电子邮件进行营销,事实上它正在工作,但我有一个问题,我必须删除参数消息to: 'exemple@gmail.com'并且不在 email 中仅显示密件抄送收件人,这是代码:

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)
});

Looking at the documentation , you should be using the sendMultiple method instead of the send method.查看文档,您应该使用sendMultiple方法而不是send方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 SendGrid 发送在本地工作但不在域上工作的电子邮件 API - Sending emails working locally but not on domain using SendGrid API C# 使用域 SMPT 或 Sendgrid 发送电子邮件? - C# sending emails using domain SMPT or Sendgrid? 在 sendgrid 中发送多个动态模板电子邮件时出现个性化字段错误 - Personalizations field error when sending multiple dynamic template emails in sendgrid 使用 SendGrid 从逻辑应用向多个收件人发送电子邮件 - Sending emails with SendGrid from a logic app to multiple recipients 使用 SendGrid 和 Amazon work 发送电子邮件 email - Send emails using SendGrid and Amazon work email 通过 SendGrid 和 Google Workspaces 发送具有相同地址的电子邮件 - Sending emails with the same address via both SendGrid and Google Workspaces 发送多封邮件时如何防止 SendGrid 节流? - How to prevent SendGrid throttling when sending multiple emails? 使用 sendgrid 发送邮件时凭据错误 - Wrong credentials in sending mail using sendgrid 如何使用Sendgrid发送个性化邮件 API C# - How to send personalized emails using Sendgrid API C# 如何使用 Laravel 将电子邮件保存在 SendGrid 上的 email 列表中? - How to save emails in an email list on SendGrid using Laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM