I am creating eml files in my Node backend using an npm package called "eml-format", and I'm trying to determine what syntax I would use to designate a "cc" on an email. This is the example they provide, in terms of what you should pass in when building the eml file:
let data = {
from: "[email protected]",
to: {
name: "Foo Bar",
email: "[email protected]"
},
subject: "Winter promotions",
text: "Lorem ipsum...",
html: '<html><head></head><body>Lorem ipsum...<br /><img src="nodejs.png" alt="" /></body></html>',
attachments: [
{
name: "sample.txt",
contentType: "text/plain; charset=utf-8",
data: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eget elit turpis. Aliquam lorem nunc, dignissim in risus at, tempus aliquet justo..."
},
{
name: "nodejs.png",
contentType: "image/png",
data: fs.readFileSync("nodejs.png"),
inline: true
}
]
};
How would I add a section to "cc" a second email address? I tried making the assignment for "to" an array, with two separate objects. But this didn't work. I also tried adding a key/value pair for {Cc: "[email protected]"}
to data
but this didn't show up in the final eml file.
Looking at the source code, it doesn't appear to have support for CC-style recipients.
It may be worth asking the maintainer to add it to bring the lib to closer parity with the spec they reference.
Additionally, you may be able to add the functionality yourself with something like:
if (typeof data.cc != "undefined") {
data.headers["Cc"] = (typeof data.cc == "string" ? data.cc : emlformat.toEmailAddress(data.cc));
}