0

I am trying to send email using following script but it's not working and throwing error:

<cfmail to="user@mydomain.com" 
            from="user@mydomain.com" 
           <!---  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>

Error is :Invalid token \ found on the <cfmailparam tag line

I have tried removing tags as well still it didn't work.

Jack
  • 989
  • 3
  • 13
  • 24

1 Answers1

9

That is not how you escape quotes in CFML. You should be able to just double them up. Like so:

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

Or you could use single-quotes to surround your values instead of double quotes. This will allow you to use double-quotes within your values. Like so:

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

Also, in your example you do not need to use <cfoutput> tags within the <cfmail> tags.

Miguel-F
  • 13,450
  • 6
  • 38
  • 63