When sending an email with an application or sendmail, using an UTF-8 encoding, some attributes must be given if you expect the email to be displayed correctly by the reader.
To start, to get the right display in the body of the email, you need to specify the encoding in the header fields by adding :
Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit
The subject is not proceed using this attribute and it must be written in a different way to be interpreted correctly:
Subject: =?utf-8?Q?éssai=20de=20sujet?=
Here, the “?utf-8?Q?” indicates what encoding to be used in the tittle, then it is followed by the title itsleft “Q” indicates that the title is in plain text. The limit of this is that the title can’t contain space, tabs or ? without being escaped firstly. The Title is ended by termination sequence “?=”
The other solution to manage title more easily is to use a base64 encoding with the “B” encoding type instead of “Q”
Subject: =?utf-8?B?base64EncodedTitle?=
This way is more easy to encode if your system handle a base64 encoding function.
Hey Paul, you forgot the source : RFC-2047 ^^
And RFC-2045 is also interesting…