如何在Strapi中一次性发送邮件给多个收件人?
解决Strapi邮件插件多收件人非法地址错误
你遇到的问题是因为Strapi邮件插件的to参数不支持逗号分隔的字符串格式,正确的多收件人传递方式是使用字符串数组。
修改后的代码示例:
await strapi.plugins['email'].services.email.send({ to: ['mail1@example.com', 'mail2@example.com'], // 用数组存储多个收件人地址 from: 'your verified email address', // 例如SendGrid中已验证的发件地址 cc: 'valid email address', bcc: 'valid email address', replyTo: 'valid email address', subject: 'The Strapi Email plugin worked successfully', text: 'Hello world!', html: 'Hello world!', });
额外说明:如果需要给cc或bcc设置多个收件人,同样可以使用数组格式,比如cc: ['cc1@example.com', 'cc2@example.com']。
内容的提问来源于stack exchange,提问作者Sajeban Rex
相关产品推荐
相关产品推荐

