ColdFusion cfmail 主题行中的特殊字符 [英] ColdFusion cfmail special characters in subject line
问题描述
邮件主题行中的特殊字符被转换为问号或方框.
Special characters in the subject line of the mail getting converted in to question marks or boxes.
我曾尝试将主题行的动态字符串包装在 URLEncodedFormat 中,但结果是徒劳的.
I have tried to wrap the dynamic string of the subject line in URLEncodedFormat , however ended up in vain.
<cfset strSubject= URLEncodedFormat(s)>
<cfmail
from="xxxxx@xx.com"
to="yyyyyyy@yyy.com"
subject="#strSubject#"
type="html"
>
#testText#
</cfmail>
推荐答案
假设特殊字符是 unicode 字符,您必须将字符串编码为 base64 格式并在主题行中使用.像这样,
Assuming the special characters are unicode charactes, you will have to encode the string to a base64 format and use that in the subject line. Like this,
<cfset strSubject="Demande d’chantillons supplémentaires">
<cfset strSubject=ToBase64(strSubject, "utf-8")>
<cfmail from="test@test.com" to="test@test.com" subject="=?utf-8?B?#strSubject#?=" type="html">
#testText#
</cfmail>
主题行的格式必须为 =?<charset>?<encoding>?<encoded text>?=
?
和 =
是必需的.
charset"可以是在 IANA 注册的任何字符集.通常这将是与消息正文相同的字符集.
"charset" may be any character set registered with IANA. Typically it would be the same charset as the message body.
"encoding" 可以是Q",表示类似的 Q 编码到引用的可打印编码,或B"表示 base64 编码.
"encoding" can be either "Q" denoting Q-encoding that is similar to the quoted-printable encoding, or "B" denoting base64 encoding.
编码文本"是 Q 编码或 base64 编码的文本.
"encoded text" is the Q-encoded or base64-encoded text.
这篇关于ColdFusion cfmail 主题行中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!