Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created September 12, 2024 12:02
Using Canonicalize() To Embed Emoji In Email Subject Lines In ColdFusion
<cfscript>
// Subject line with a left-arrow HTML entity and an eyes-emoji HTML entity.
subject = "&larr; Hello, is it me you're looking for &##x1f440;?";
// Try sending with embedded HTML entities.
sendEmail( subject );
// Try sending with canonicalized HTML entities.
sendEmail( canonicalize( subject, false, false ) );
// ------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------- //
/**
* I send a test email with the given subject line.
*/
public void function sendEmail( required string subject ) {
cfmail(
to = "ben@example.com",
from = "no-reply@example.com",
subject = subject,
type = "text/html",
server = "127.0.0.1",
port = 1025,
spoolEnable = false
) {
writeOutput( "<h1> Hello There </h1>" );
};
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment