简体   繁体   English

放置多个接收方时 sendgrid 邮件发送错误

[英]sendgrid mail sending error upon placing multiple receiver

I'm using const sgMail = require('@sendgrid/mail');我正在使用const sgMail = require('@sendgrid/mail'); and utilizing sendgrid version 7.6.2.并使用 sendgrid 7.6.2 版。

When I'm adding two email addresses in array and passing that into send() or sendMultiple() it's throwing me error like this.当我在数组中添加两个 email 地址并将其传递send()sendMultiple()时,它会抛出这样的错误。

status: 'failed',
>    Error: Error: String expected for `email`

here's the section where I'm putting the multiple emails,这是我放置多封电子邮件的部分,

mailsTo = {
    email: ["demo@email.com", "demo1@email.com"],
    name: "demo",
    type: 'to'
}

here if I pass one email as in form of string the mail is getting triggered.在这里,如果我以字符串的形式传递一个 email,则邮件将被触发。 Can anyone please suggest what am I doing wrong.谁能建议我做错了什么。

Thanks in advance提前致谢

According to the documentation the addresses are to be passed as an array of EmailData (string or object with email and name ).根据文档,地址将作为EmailData数组(字符串或 object 与emailname )传递。

Please try the following:请尝试以下方法:

mailsTo = [
    {
        email: "demo@email.com",
        name: "demo"
    },
    {
        email: "demo1@email.com",
        name: "demo"
    }
]

Assuming mailsTo is being pass as the to parameter for假设mailsTo被作为to参数传递

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM