cfmail is not working properly

399 views Asked by At

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

<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>

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

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

1

There are 1 answers

2
Miguel-F On

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.