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

求助:使用AWS JS SDK v3 SES时出现‘Invalid email address’错误

解决AWS SES V3 SDK发送邮件时的"Invalid email address"错误
  • 问题根源:代码里ReturnPath、ReturnPathArn、SourceArn字段设置了空字符串,SES V3 SDK会严格校验这些字段格式,空字符串不符合邮箱地址或ARN的格式要求,触发错误。而V2 SDK会自动忽略空值的可选字段,所以不会出现该问题。

  • 修复方案:移除这些空字符串的可选字段,若有需要再填入合法有效值:

修改后的代码:

const { SESClient, SendEmailCommand } = require("@aws-sdk/client-ses");

void async function() {
  const client = new SESClient({ region: 'us-east-1' });

  const input = {
    "Destination": {
      "BccAddresses": [],
      "CcAddresses": [],
      "ToAddresses": [
        "erik@example.com"
      ]
    },
    "Message": {
      "Body": {
        "Html": {
          "Charset": "UTF-8",
          "Data": "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>."
        },
        "Text": {
          "Charset": "UTF-8",
          "Data": "This is the message body in text format."
        }
      },
      "Subject": {
        "Charset": "UTF-8",
        "Data": "Test email"
      }
    },
    "ReplyToAddresses": [],
    "Source": "updates@example.io"
  };
  const command = new SendEmailCommand(input);
  const response = await client.send(command);
  console.log(response);
}();
  • 补充说明:如果确实需要使用ReturnPath或ARN相关字段,必须填入符合格式的合法邮箱地址或SES ARN,不能留空字符串。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 18:22:41