CFMAIL工作不正常

问题描述:

我尝试使用下面的脚本来发送电子邮件,但它不工作和投掷的错误:CFMAIL工作不正常

<cfmail to="[email protected]" 
      from="[email protected]" 
      <!--- subject="#sub#" ---> 
      type="html" 
      server="smtp.sendgrid.net" 
      timeout="360" 
      username="un" 
      password="psw" > 

      <cfmailparam name="X-SMTPAPI" value="{\"category\":\"Cool Emails\"}"> 
      <cfoutput> 
       Hello 
      </cfoutput> 
    </cfmail> 

错误是:无效令牌\上<cfmailparam tag line

发现我已经尝试删除标签以及它仍然没有工作。

+2

你试过去了哪些标签,以及“仍然没有工作”的细节? –

这不是你如何在CFML中转义引号。你应该能够把它们加倍。像这样:

<cfmailparam name="X-SMTPAPI" value="{""category"":""Cool Emails""}"> 

或者你可以用单引号括住你的值而不是双引号。这将允许你在你的值中使用双引号。像这样:

<cfmailparam name='X-SMTPAPI' value='{"category":"Cool Emails"}'> 

而且,在你的榜样,你不需要在<cfmail>标签中使用<cfoutput>标签。

+0

有时您需要在cfmail块中使用cfoutput标签。这不是其中之一。 –

+0

这就是我的意思丹;在这个例子中,他们并不需要。我会在我的回答中澄清。 –