【问题标题】:InvalidParameterValue: Duplicate header 'Content-Transfer-Encoding'InvalidParameterValue:重复的标头“内容传输编码”
【发布时间】:2020-03-06 03:48:46
【问题描述】:

当我尝试通过电子邮件发送附件时,我收到了这个错误,谁能告诉我我做错了什么这里是我尝试过的代码

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

【问题讨论】:

    标签: node.js character-encoding amazon-ses


    【解决方案1】:

    如果您使用 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--`;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多