You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过SendGrid API单请求批量发送邮件?

SendGrid 单次请求发送多封邮件的API端点说明

SendGrid的/mail/send端点其实是支持单次请求发送多封邮件的,你之前可能是请求格式不对。

具体用法

直接向/mail/send端点发送一个包含多个邮件对象的数组即可,逻辑和你用sendMultiple(messages)完全一致。

举个Node.js原生请求的示例(用axios):

const axios = require('axios');

// 构造多封邮件的数组
const batchMessages = [
  {
    to: 'user1@example.com',
    from: 'your-sender@example.com',
    subject: '批量测试邮件1',
    text: '这是第一封批量发送的邮件内容'
  },
  {
    to: 'user2@example.com',
    from: 'your-sender@example.com',
    subject: '批量测试邮件2',
    text: '这是第二封批量发送的邮件内容'
  }
];

// 发起批量请求
axios.post('https://api.sendgrid.com/v3/mail/send', batchMessages, {
  headers: {
    'Authorization': 'Bearer 你的SendGrid API密钥',
    'Content-Type': 'application/json'
  }
})
.then(res => console.log('批量发送完成'))
.catch(err => console.error('发送出错:', err.response.data));

注意事项

  • 每个邮件对象必须符合SendGrid的格式要求,必填字段包括to、from、subject,以及text或html内容字段。
  • 单次请求最多支持发送1000封邮件,超过这个数量需要拆分多个请求。
  • 你用的sendMultiple方法本质就是封装了这个批量请求逻辑,底层调用的就是/mail/send端点。

内容的提问来源于stack exchange,提问作者Tholinhlanhla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 10:35:02