fix: corretto invio da mail (scrittura diretta nel db). feat: aggiunta gestione di gruppi interni per l'invio delle mail
This commit is contained in:
+10
-1
@@ -60,7 +60,7 @@ async function getAccessToken() {
|
||||
* @param {Array} [options.inlineImages] - [{ cid, content (base64), contentType }]
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments = [], inlineImages = [] }) {
|
||||
async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments = [], inlineImages = [], inReplyTo, references }) {
|
||||
const sender = process.env.AZURE_MAIL_SENDER;
|
||||
if (!sender) throw new Error('AZURE_MAIL_SENDER non configurato nel .env');
|
||||
|
||||
@@ -94,6 +94,14 @@ async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments
|
||||
})),
|
||||
];
|
||||
|
||||
const headers = [];
|
||||
if (inReplyTo) {
|
||||
headers.push({ name: 'In-Reply-To', value: inReplyTo });
|
||||
}
|
||||
if (references) {
|
||||
headers.push({ name: 'References', value: references });
|
||||
}
|
||||
|
||||
const payload = {
|
||||
message: {
|
||||
subject,
|
||||
@@ -105,6 +113,7 @@ async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments
|
||||
ccRecipients,
|
||||
bccRecipients,
|
||||
attachments: allAttachments,
|
||||
internetMessageHeaders: headers.length ? headers : undefined,
|
||||
},
|
||||
saveToSentItems: false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user