ColdFusion cfmail 主题行中的特殊字符
邮件主题行中的特殊字符将转换为问号或方框。
我尝试将主题行的动态字符串包装在 URLEncodedFormat 中,但最终徒劳无功。
<cfset strSubject= URLEncodedFormat(s)>
<cfmail
from="[email protected]"
to="[email protected]"
subject="#strSubject#"
type="html"
>
#testText#
</cfmail>
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="[email protected]"
to="[email protected]"
subject="#strSubject#"
type="html"
>
#testText#
</cfmail>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设特殊字符是 unicode 字符,您必须将字符串编码为 base64 格式并在主题行中使用它。像这样,
主题行的格式必须为
=????=
?
和= 为必填项。
MIME - 编码字
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,
The subject line must be in the format
=?<charset>?<encoding>?<encoded text>?=
The
?
and=
are required.MIME - Encoded Word
另外:将 charset="utf-8" 添加到 cfmail 标记。如果您在主题中使用 utf-8,那么您可能也会在正文中使用它。
Also: add charset="utf-8" to the cfmail tag. If you are using utf-8 in the subject, you will probably also use it in the body.
就我而言,我只需在执行
cfmail
操作的页面顶部包含
即可。使用CF2018。In my case, I just had to include
<cfprocessingdirective pageencoding="utf-8">
at the top of the page doing thecfmail
ing. Using CF2018.