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,
|
||||
};
|
||||
|
||||
+3
-1
@@ -29,7 +29,7 @@ function getTransporter() {
|
||||
* Invia una email tramite SMTP (nodemailer).
|
||||
* Stessa interfaccia di graphMailer.sendMail.
|
||||
*/
|
||||
async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments = [], inlineImages = [] }) {
|
||||
async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments = [], inlineImages = [], inReplyTo, references }) {
|
||||
const transporter = getTransporter();
|
||||
|
||||
const mailOptions = {
|
||||
@@ -39,6 +39,8 @@ async function sendMail({ to, cc = [], bcc = [], subject, bodyHtml, attachments
|
||||
bcc: bcc.length ? bcc.join(', ') : undefined,
|
||||
subject,
|
||||
html: bodyHtml,
|
||||
inReplyTo,
|
||||
references,
|
||||
attachments: [
|
||||
...attachments.map(a => ({
|
||||
filename: a.filename,
|
||||
|
||||
Reference in New Issue
Block a user