deno-smtp icon indicating copy to clipboard operation
deno-smtp copied to clipboard

diacritical characters on subject field will not be interpreted correctly with icloud.com mail boxes

Open chisNaN opened this issue 4 years ago • 3 comments

Hello Sir thanks for this contribution

Here is my workaround:

import * as base64 from "https://denopkg.com/chiefbiiko/base64/mod.ts";
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts"

const diacritic = 'ça va?'
const b64: string = base64.fromUint8Array(new TextEncoder().encode(diacritic));

console.log(b64)
console.log(btoa(diacritic)) // will not output the same as previous

const to = '[email protected]'
const content = 'content with àccent'
const client = new SmtpClient({ content_encoding: "7bit" })
const subject = `=?utf-8?B?${b64}?=`

const connectConfig: any = { hostname: "in-v3.mailjet.com", port: 465, username: "", password: '' }
      
await client.connectTLS(connectConfig)
await client.send({ from: '[email protected]', to, subject, content })
await client.close()
console.log('finish')

:bulb: Note that I had to do the same thing (which is only documented in the official commands of smtp) for the node smtp-client package

chisNaN avatar Nov 20 '20 09:11 chisNaN

Sorry, I don't know anything about "diacritical characters". Can you submit PR and use specific test cases to solve your problem?

manyuanrong avatar Nov 21 '20 05:11 manyuanrong

Ok but its simple to test. Just send you an email with Latin accents (or chineese symbols if you prefer) character in your subject to an iCloud inbox and you will see the results diacritic

chisNaN avatar Nov 21 '20 10:11 chisNaN

Thank you so much for the workaround, @chisNaN!

rojvv avatar Jul 05 '23 20:07 rojvv