1

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

firstname.o'flanagan@example.com

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.

Community
  • 1
  • 1
  • Can you send to that address without using ColdFusion? – Dan Bracuk Aug 19 '13 at 22:56
  • What actually happens when you try? – Dan Bracuk Aug 20 '13 at 00:01
  • Is it a single quote, or is it one of the stupid things Microsoft Word converts single quotes to? – Peter Boughton Aug 20 '13 at 08:42
  • I just did a tag using firstname.o'flanagan@example.com as the to and from attribute without any problems on CF10. I didn't even use preservesinglequotes. I'd check your variable build up. – Dana Kowalski Aug 20 '13 at 13:26
  • This could be conventions on your mail server as well. Try escaping with a backslash (that's the old convention I think - circa 1999). I would also tail the mail server log to see what it's telling you, and to see what it sees as the address (maybe it's mangling it). – Mark A Kruger Aug 20 '13 at 14:00

1 Answers1

0

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.

Lance
  • 3,193
  • 2
  • 32
  • 49