ColdFusion中cfmail特殊字符的主题行 [英] ColdFusion cfmail special characters in subject line

查看:276
本文介绍了ColdFusion中cfmail特殊字符的主题行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

邮件主题行中的特殊字符已转换为问号或框。



我试图将主题行的动态字符串包装在URLEncodedFormat中,但最终无效。

 < cfset strSubject = URLEncodedFormat(s)> 
< cfmail
from =xxxxx@xx.com
to =yyyyyyy@yyy.com
subject =#strSubject#
type = html
>
#testText#
< / cfmail>


解决方案

假设特殊字符是unicode字符,将字符串编码为base64格式并在主题行中使用。像这样,

 < cfset strSubject =Demande d'chantillonssupplémentaires> 
< cfset strSubject = ToBase64(strSubject,utf-8)>

< cfmail from =test@test.comto =test@test.comsubject ==?utf-8?B?#strSubject#?=type =html >
#testText#
< / cfmail>

主题行的格式必须为 =?< charset> ;? < encoding>?< encoded text>?=



= 是必填项。



MIME - 编码字


字符集< 可以是在IANA注册的任何字符集。

encoding 可以是Q表示Q-编码,类似于
到quoted-printable编码,或B表示base64编码。



编码文本 Q编码或base64编码的文本。



Special characters in the subject line of the mail getting converted in to question marks or boxes.

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>

解决方案

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>

The subject line must be in the format =?<charset>?<encoding>?<encoded text>?=

The ? and = are required.

MIME - Encoded Word

"charset" may be any character set registered with IANA. Typically it would be the same charset as the message body.

"encoding" can be either "Q" denoting Q-encoding that is similar to the quoted-printable encoding, or "B" denoting base64 encoding.

"encoded text" is the Q-encoded or base64-encoded text.

这篇关于ColdFusion中cfmail特殊字符的主题行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆