Tobias Rapp wrote:
> Thanks Arno for the help.
> Would it also work if I would set Allow8BitChars to TRUE, Charset to
> "UTF-8" and manually encode all string properties like "HdrTo",
> "HdrSubject" and "MailMessage.Text" using Utf8Encode()?

Just Utf8Encode() isn't enough. In headers only 7-bit ASCII is allowed.
You would have to MIME-inline-encode those header lines yourself. This
is rather difficult, especially when header lines have to be wrapped
around since their length actually is limited and should not exceed
76 bytes plus 2 bytes for the CR/LF (I've seen mails completely 
re-encoded by some MTA when header lines exceeded this limit).

So if you use UTF-8 encoded strings and set Charset = 'UTF-8' and both 
Allow8BitChars and ConvertToCharset to FALSE. MailMessage.Text then
has to contain UTF-8 text as well and the component will MIME encode
the content if required (if at least one 8-bit character is found in
MailMessage.Text). This is the safest way, even though most email 
programs and MTAs are capable to handle 8-bit text content today I 
would not rely on that.
> My assumption was that the header lines should not contain non-ASCII
> characters, but maybe it is legal to use UTF-8 if the header also
> declares something like
> Content-Type: text/plain; charset="UTF-8"
> What is your opinion?

See above, the charset in content-type as well as the transfer-encoding
header is related to the content not to the header itself. Currently 
TSmtpCli's 'smart mode' as described above doesn't allow 8-bit chars in
text content.  

Arno Garrels
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to