Skip to content

Commit

Permalink
fix: Split to, cc, and bcc on semicolons as well as commas
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Apr 8, 2021
1 parent 0d1fb36 commit 6cce921
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions models/protocols/SendGridProtocol.cfc
Expand Up @@ -41,15 +41,15 @@ component extends="cbmailservices.models.AbstractProtocol" {

body[ "subject" ] = mail.subject;

var tos = isArray( mail.to ) ? mail.to : mail.to.listToArray();
var tos = isArray( mail.to ) ? mail.to : arraySlice( mail.to.split( "[,;]\s*" ), 1 );
var personalization = {
"to": tos.map( function( to ) {
return { "email": to };
} )
};

if ( mail.keyExists( "bcc" ) ) {
mail.bcc = isArray( mail.bcc ) ? mail.bcc : mail.bcc.listToArray();
mail.bcc = isArray( mail.bcc ) ? mail.bcc : arraySlice( mail.bcc.split( "[,;]\s*" ), 1 );
if ( ! mail.bcc.isEmpty() ) {
personalization[ "bcc" ] = mail.bcc.map( function( address ) {
return { "email" = address };
Expand All @@ -58,7 +58,7 @@ component extends="cbmailservices.models.AbstractProtocol" {
}

if ( mail.keyExists( "cc" ) ) {
mail.cc = isArray( mail.cc ) ? mail.cc : mail.cc.listToArray();
mail.cc = isArray( mail.cc ) ? mail.cc : arraySlice( mail.cc.split( "[,;]\s*" ), 1 );
if ( ! mail.cc.isEmpty() ) {
personalization[ "cc" ] = mail.cc.map( function( address ) {
return { "email" = address };
Expand Down

0 comments on commit 6cce921

Please sign in to comment.