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 réponses
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
répondu il y a un an
  • 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>"

répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions