CFMail not sending to email address that has a single quote in it

935 Views Asked by At

How can I use cfmail to send an email to an address that has a single quote in it? For example:

firstname.o'[email protected]

For some reason I can't get an email sent to that address no matter what I do. Here's the cfmail tag code I'm using. I've tested all the variables and they're all defined:

<cfmail from="#getEmail.from_email#" 
        to="#email#" 
        subject="#getEmail.subject#" 
        type="HTML" 
        cc="#cc_email#" 
        bcc="#attributes.bcc_email#" 
        charset="UTF-8">

Am I missing something? Thanks for the help.

1

There are 1 best solutions below

4
On BEST ANSWER

Did you try

<cfmail from="#getEmail.from_email#"
 to="#preserveSingleQuotes(email)#" 
 subject="#getEmail.subject#" type="HTML" 
  cc="#cc_email#" bcc="#attributes.bcc_email#" charset="UTF-8">

using the PreserveSingleQuotes should allow you to send to that address. Unfortunately using a single quote is valid in an email.