Encode special char in SES mail template

0

Hi,

I'm using SES to send email from template. In my template i have some special chars (é, è, à)

I receive this mail with char like this : éété enregistréeé instead of this "été enregistréeé

In my template i added encoding this without success. Itried too UTF8 without more results

<!doctype html><html><head><meta charset=\"ISO-8859-1\"></head><body>été enregistrée</body></html>

For this i use node js to send mail

let params = {
      Source: 'test@outlook.com',
      Template: templateName,
      Destination: {
        ToAddresses: [ 
          recipientEmail
        ]
      },
      TemplateData: JSON.stringify(data)
    };
    let res = {};
    try{
      res = await AWS_SES.sendTemplatedEmail(params).promise();
    }
    catch (e) {
      console.log(e);
      res = e;
      throw(e); 
    }

Someone has a solution to send this chars correctly formated?

Thanks

2개 답변
0

Email needs a lot of encoding. The default for email is to have 7bit us-ascii data only and body parts then need to be encoded using quoted-printable or base64. But since most (if not all) mail systems and readers support 8bit data, you can make an html body part look like this:

Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<!doctype html><html><head><meta charset="utf-8"></head><body>été enregistrée</body></html> 

make sure your template is actually in the utf-8 charset and this should work fine. Note that the charset in the email headers should be the same as the one mentioned in the html meta tag.

AWS
JohnAWS
답변함 일 년 전
  • Thanks for your reply but don't understand everything. Where do i have to add the first two lines "Content-Type? Inside HtmlPart of my temple?

0

i've tried to send email by retrieving first the template and then send with sendRawEmail. When i get back the html from the template. It's not correctly encoded and i have this back

"<!doctype html><html><head><meta http-equiv="Content-Type" Content="text/html"; charset="UTF-8"></head><body><h1>Bonjour,</h1><p>Une personne a utilisé le formulaire de contact du site. à é è </p><ul><li>Nom: {{name}}</li><li>Email: {{email}}</li><li>Sujet: {{subject}}</li></ul><p>Message:</br>{{message}}</p><p>Cordialement,</br>Kids&Fun,</p></body></html>"

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠