我创建了 SES 模板并从 aws-cli 呈现它,如您所见,非英语文本被替换为“?”,无论是纯文本版本还是 HTML 版本。如何解决这个问题? P.S:我也通过发送电子邮件进行了检查。

以下是我的 TestMainTemplate.json 文件

{
        "Template": {
            "TemplateName": "TestTemplate01",
            "SubjectPart": "こんにちは {{name}}!",
            "HtmlPart": "<h1>こんにちは {{name}}さん</h1><p>あなたの好きなAWSサービスは{{favoriteservice}}ですね。</p>",
            "TextPart": "前略 {{name}}さん\r\nあなたの好きなAWSサービスは{{favoriteservice}}ですね。\r\n草々"
        }
    }

命令从 cli 将模板上传到 aws SES:
aws ses create-template --cli-input-json file://TestMainTemplate.json --region us-east-1
渲染模板的命令:
aws ses test-render-template --template-name TestTemplate01 --template-data '{ "name": "大栗" , "favoriteservice": "SES" }' --region us-east-1
输出:
Date: 2018-09-14T03:27:46.913Z
Message-ID: <[email protected]>
Subject: ????? ??!
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_Part_106793_202759574.1536895666913"
Content-Transfer-Encoding: quoted-printable

------=_Part_106793_202759574.1536895666913
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

?? ????
???????AWS?????SES????
??
------=_Part_106793_202759574.1536895666913
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<h1>????? ????</h1><p>???????AWS?????SES????</p>
------=_Part_106793_202759574.1536895666913--

最佳答案

我怀疑您的终端未设置为 UTF-8。 echo $LANG 说什么?就我而言,它是:

$ echo $LANG
en_NZ.UTF-8

我尝试了上面的步骤并得到了一个有效的 base64 编码文本:
$ aws --output text ses test-render-template --template-name TestTemplate01 --template-data '{ "name": "大栗" , "favoriteservice": "SES" }' --region us-east-1
Date: 2018-09-15T23:36:13.701Z
Message-ID: <143...>
Subject: =?UTF-8?B?44GT44KT44Gr44Gh44GvIOWkp+aglyE=?=
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_Part_237228_701472298.1537054573701"
Content-Transfer-Encoding: quoted-printable

------=_Part_237228_701472298.1537054573701
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64

5YmN55WlIOWkp+agl+OBleOCkw0K44GC44Gq44Gf44Gu5aW944GN44GqQVdT44K144O844OT44K5
44GvU0VT44Gn44GZ44Gt44CCDQrojYnjgIU=
------=_Part_237228_701472298.1537054573701
[... etc ...]

另外你的 aws-cli 版本是什么?
$ aws --version
aws-cli/1.14.14 Python/2.7.12 Linux/4.15.0-34-generic botocore/1.8.18

显然我的已经很老了(当前是 1.16.14)并且 SES 命令仍然按预期工作。

我很确定这是您的终端编码有问题。它必须设置为 UTF-8 才能工作。

关于amazon-web-services - SES 模板/电子邮件无法呈现日语文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52324663/

10-11 10:27