-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from SparkPost/cc-and-bcc
added CC and BCC sugar
- Loading branch information
Showing
6 changed files
with
367 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
var key = 'YOURAPIKEY' | ||
, SparkPost = require('sparkpost') | ||
, client = new SparkPost(key) | ||
, transmission = { | ||
recipients: [ | ||
{ | ||
address: { | ||
email: 'original.recipient@example.com', | ||
name: 'Original Recipient' | ||
}, | ||
substitution_data: { | ||
recipient_type: 'Original' | ||
} | ||
} | ||
], | ||
bcc: [ | ||
{ | ||
address: { | ||
email: 'bcc.recipient@example.com', | ||
}, | ||
substitution_data: { | ||
recipient_type: 'BCC' | ||
} | ||
} | ||
], | ||
content: { | ||
from: { | ||
name: 'Node BCC Test', | ||
email: 'from@example.com' | ||
}, | ||
subject: 'Example email using bcc', | ||
text: 'An example email using bcc with SparkPost to the {{recipient_type}} recipient.', | ||
html: '<p>An example email using bcc with SparkPost to the {{recipient_type}} recipient.</p>' | ||
} | ||
}; | ||
|
||
// Promise | ||
client.transmissions.send(transmission) | ||
.then(data => { | ||
console.log('Congrats! You sent an email with bcc using SparkPost!'); | ||
console.log(data); | ||
}) | ||
.catch(err => { | ||
console.log('Whoops! Something went wrong'); | ||
console.log(err); | ||
}); | ||
|
||
// Callback | ||
client.transmissions.send(transmission, function(err, data) { | ||
if (err) { | ||
console.log('Whoops! Something went wrong'); | ||
console.log(err); | ||
} else { | ||
console.log('Congrats! You sent an email with bcc using SparkPost!'); | ||
console.log(data); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
'use strict'; | ||
|
||
var key = 'YOURAPIKEY' | ||
, SparkPost = require('sparkpost') | ||
, client = new SparkPost(key) | ||
, transmission = { | ||
recipients: [ | ||
{ | ||
address: { | ||
email: 'original.recipient@example.com', | ||
name: 'Original Recipient' | ||
}, | ||
substitution_data: { | ||
recipient_type: 'Original' | ||
} | ||
}, | ||
], | ||
cc: [ | ||
{ | ||
address: { | ||
email: 'cc.recipient@example.com', | ||
name: 'Carbon Copy Recipient', | ||
}, | ||
substitution_data: { | ||
recipient_type: 'CC' | ||
} | ||
} | ||
], | ||
content: { | ||
from: { | ||
name: 'Node CC Test', | ||
email: 'from@example.com' | ||
}, | ||
subject: 'Example email using cc', | ||
text: 'An example email using cc with SparkPost to the {{recipient_type}} recipient.', | ||
html: '<p>An example email using cc with SparkPost to the {{recipient_type}} recipient.</p>' | ||
} | ||
}; | ||
|
||
// Promise | ||
client.transmissions.send(transmission) | ||
.then(data => { | ||
console.log('Congrats! You sent an email with cc using SparkPost!'); | ||
console.log(data); | ||
}) | ||
.catch(err => { | ||
console.log('Whoops! Something went wrong'); | ||
console.log(err); | ||
}); | ||
|
||
// Callback | ||
client.transmissions.send(transmission, function(err, data) { | ||
if (err) { | ||
console.log('Whoops! Something went wrong'); | ||
console.log(err); | ||
} else { | ||
console.log('Congrats! You sent an email with cc using SparkPost!'); | ||
console.log(data); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.