Jesper5mo ago

Non-ascii characters not showing in subject field using Deno SMTP

When using the smtp library non-ascii characters show up fine in the body. But if included in the header they simply disappear.
1 Reply
Deno AI Helper
Deno AI Helper5mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it sounds like there might be an issue with the encoding of non-ASCII characters in the subject field of your SMTP messages. In general, email headers, including the subject field, need to be encoded if they contain non-ASCII characters. This is typically done using MIME encoded-word syntax, as specified in RFC 2047. If the SMTP library you're using in Deno doesn't handle this encoding automatically, you may need to encode the subject field yourself. For example, if you're trying to set a subject with non-ASCII characters, you might need to use something like =?utf-8?B? followed by the base64-encoded version of your subject, and then ?= to close the encoding. Here's a rough example of what this might look like:
Subject: =?utf-8?B?WW91ciBFbmNvZGVkIFN1YmplY3Q=?=
Subject: =?utf-8?B?WW91ciBFbmNvZGVkIFN1YmplY3Q=?=
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice and consult the documentation or community resources for the specific SMTP library you are using in Deno for further assistance.