diff --git a/lib/models/index.d.ts b/lib/models/index.d.ts index 4287ad5..a5996b9 100644 --- a/lib/models/index.d.ts +++ b/lib/models/index.d.ts @@ -364,6 +364,10 @@ export interface MessageCreateOptions { * The email address to which the email will be sent. Must be a verified email address. */ to?: string; + /** + * The email address to which the email will be CC'd to. Must be a verified email address. + */ + cc?: string; /** * Allows for the partial override of the message's 'from' address. This **must** be an address ending with `YOUR_SERVER.mailosaur.net`, such as `my-emails@a1bcdef2.mailosaur.net`. */ @@ -398,6 +402,10 @@ export interface MessageForwardOptions { * The email address to which the email will be sent. Must be a verified email address. */ to: string; + /** + * The email address to which the email will be CC'd to. Must be a verified email address. + */ + cc?: string; /** * Any plain text to include when forwarding the message. Note that only text or html can be supplied, not both. */ @@ -412,6 +420,10 @@ export interface MessageForwardOptions { * Options to use when replying to a message. */ export interface MessageReplyOptions { + /** + * The email address to which the email will be CC'd to. Must be a verified email address. + */ + cc?: string; /** * Any additional plain text content to include in the reply. Note that only text or html can be supplied, not both. */ diff --git a/lib/models/messageCreateOptions.js b/lib/models/messageCreateOptions.js index 42e61f1..fdb3211 100644 --- a/lib/models/messageCreateOptions.js +++ b/lib/models/messageCreateOptions.js @@ -1,6 +1,7 @@ class MessageCreateOptions { constructor(data = {}) { this.to = data.to; + this.cc = data.cc; this.from = data.from; this.send = data.send; this.subject = data.subject; diff --git a/lib/models/messageForwardOptions.js b/lib/models/messageForwardOptions.js index f1e8104..9e677f6 100644 --- a/lib/models/messageForwardOptions.js +++ b/lib/models/messageForwardOptions.js @@ -1,6 +1,7 @@ class MessageForwardOptions { constructor(data = {}) { this.to = data.to; + this.cc = data.cc; this.text = data.text; this.html = data.html; } diff --git a/lib/models/messageReplyOptions.js b/lib/models/messageReplyOptions.js index 374d48c..f49cf48 100644 --- a/lib/models/messageReplyOptions.js +++ b/lib/models/messageReplyOptions.js @@ -3,6 +3,7 @@ class MessageReplyOptions { this.text = data.text; this.html = data.html; this.attachments = data.attachments; + this.cc = data.cc; } } diff --git a/test/emails.js b/test/emails.js index 0537b17..8d1fc3a 100644 --- a/test/emails.js +++ b/test/emails.js @@ -383,6 +383,22 @@ describe('emails', () => { assert.equal(message.subject, subject); }); + it('send with HTML content to CC recipient', async () => { + const subject = 'CC Message'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + const message = await client.messages.create(server, { + to: `anything@${verifiedDomain}`, + send: true, + subject, + cc: ccRecipient, + html: '
This is a new email.
' + }); + assert.isNotEmpty(message.id); + assert.equal(message.subject, subject); + assert.equal(message.cc.length, 1); + assert.equal(message.cc[0].email, ccRecipient); + }); + it('send with attachment', async () => { const subject = 'New message with attachment'; @@ -434,6 +450,22 @@ describe('emails', () => { assert.isNotEmpty(message.id); assert.isTrue(message.html.body.indexOf(body) >= 0); }); + + it('forward with HTML content to CC recipient', async () => { + const targetEmailId = emails[0].id; + const body = 'Forwarded HTML message.
'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + + const message = await client.messages.forward(targetEmailId, { + to: `anything@${verifiedDomain}`, + html: body, + cc: ccRecipient + }); + assert.isNotEmpty(message.id); + assert.isTrue(message.html.body.indexOf(body) >= 0); + assert.equal(message.cc.length, 1); + assert.equal(message.cc[0].email, ccRecipient); + }); }); (verifiedDomain ? describe : describe.skip)('reply', () => { @@ -459,6 +491,21 @@ describe('emails', () => { assert.isTrue(message.html.body.indexOf(body) >= 0); }); + it('reply with HTML content to CC recipient', async () => { + const targetEmailId = emails[0].id; + const body = 'Reply HTML message.
'; + const ccRecipient = `someoneelse@${verifiedDomain}`; + + const message = await client.messages.reply(targetEmailId, { + html: body, + cc: ccRecipient + }); + assert.isNotEmpty(message.id); + assert.isTrue(message.html.body.indexOf(body) >= 0); + assert.equal(message.cc.length, 1); + assert.equal(message.cc[0].email, ccRecipient); + }); + it('reply with attachment', async () => { const targetEmailId = emails[0].id;