[英]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.