InvalidParameterValue: дубликат заголовка 'Content-Transfer-Encoding' - PullRequest
0 голосов
/ 05 марта 2020

когда я пытаюсь отправить вложение с электронным письмом, я получил эту ошибку, может кто-нибудь сказать мне, что я делаю не так, вот код, который я попробовал

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"
  };

1 Ответ

1 голос
/ 05 марта 2020

Если вы используете 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--`;
...