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 Answers
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
answered a year ago
  • 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>"

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions