无效参数值:重复 header 'Content-Transfer-Encoding'

InvalidParameterValue: Duplicate header 'Content-Transfer-Encoding'

当我尝试通过电子邮件发送附件时出现此错误任何人都可以告诉我我做错了什么这是我试过的代码

var payload = `From: 'Amarjeet Singh' <${sender}>
To: ${recipient}
Subject: AWS SES Attachment
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
--NextPart
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
This is the <b>body</b> of the email.
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: application/json; charset=UTF-8; 
Content-Disposition: attachment; filename="colors.json"
Content-Transfer-Encoding: base64
${file}
--NextPart--`;

var params = {
    RawMessage: {
      Data: payload
    },
    Source: "xyz@gmail.com"
  };

如果您使用的是 AWS SES,您的负载有两个问题,首先您的边界不同,其次请记住换行符,您的字符串模板应该是这样的:

var payload = `From: 'Amarjeet Singh' <${sender}>
To: ${recipient}
Subject: AWS SES Attachment
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887

--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

This is the <b>body</b> of the email.

--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887
Content-Type: application/json; charset=UTF-8; 
Content-Disposition: attachment; filename="colors.json"
Content-Transfer-Encoding: base64

${file}
--7f1a313ee430f85a8b054f085ae67abd6ee9c52aa8d056e7f7e19c6e2887--`;