From c5883e0f51cf49d4ca115d2e88bdaf08f278717c Mon Sep 17 00:00:00 2001 From: jsrozner <1113285+jsrozner@users.noreply.github.com> Date: Wed, 26 Apr 2023 15:27:10 -0700 Subject: [PATCH] Add BCC support (same as CC), though we do not check if data.headers[BCc] is present) --- lib/eml-format.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/eml-format.js b/lib/eml-format.js index e1646a9..abcf836 100644 --- a/lib/eml-format.js +++ b/lib/eml-format.js @@ -354,7 +354,11 @@ emlformat.build = function(data, options, callback) { if (typeof data.cc != "undefined") { data.headers["Cc"] = (typeof data.cc == "string" ? data.cc : emlformat.toEmailAddress(data.cc)); } - + + if (typeof data.bcc != "undefined") { + data.headers["Bcc"] = (typeof data.bcc == "string" ? data.bcc : emlformat.toEmailAddress(data.bcc)); + } + if (!data.headers["To"]) { throw new Error("Missing 'To' e-mail address!"); } @@ -481,6 +485,13 @@ emlformat.read = function(eml, options, callback) { if (data.headers["Cc"]) { result.cc = emlformat.getEmailAddress(data.headers["Cc"]); } + if (data.headers["BCC"]) { + result.bcc = emlformat.getEmailAddress(data.headers["BCC"]); + } + if (data.headers["Bcc"]) { + result.bcc = emlformat.getEmailAddress(data.headers["Bcc"]); + } + result.headers = data.headers; //Appends the boundary to the result