mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
🐛 Keep BCC headers when sending email - Gmail node (#2721)
* 🐛 Keep BCC headers when sending email * ⚡ Fix typo Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
ebd4aa4c31
commit
9639742cc6
|
@ -49,7 +49,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
body,
|
body,
|
||||||
qs,
|
qs,
|
||||||
uri: uri || `https://www.googleapis.com${endpoint}`,
|
uri: uri || `https://www.googleapis.com${endpoint}`,
|
||||||
qsStringifyOptions:{
|
qsStringifyOptions: {
|
||||||
arrayFormat: 'repeat',
|
arrayFormat: 'repeat',
|
||||||
},
|
},
|
||||||
json: true,
|
json: true,
|
||||||
|
@ -156,6 +156,7 @@ export async function encodeEmail(email: IEmail) {
|
||||||
references: email.reference,
|
references: email.reference,
|
||||||
subject: email.subject,
|
subject: email.subject,
|
||||||
text: email.body,
|
text: email.body,
|
||||||
|
keepBcc: true,
|
||||||
} as IDataObject;
|
} as IDataObject;
|
||||||
if (email.htmlBody) {
|
if (email.htmlBody) {
|
||||||
mailOptions.html = email.htmlBody;
|
mailOptions.html = email.htmlBody;
|
||||||
|
@ -172,14 +173,15 @@ export async function encodeEmail(email: IEmail) {
|
||||||
mailOptions.attachments = attachments;
|
mailOptions.attachments = attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mail = new mailComposer(mailOptions).compile();
|
||||||
|
|
||||||
const mail = new mailComposer(mailOptions);
|
// by default the bcc headers are deleted when the mail is built.
|
||||||
|
// So add keepBcc flag to averride such behaviour. Only works when
|
||||||
|
// the flag is set after the compilation.
|
||||||
|
//https://nodemailer.com/extras/mailcomposer/#bcc
|
||||||
|
mail.keepBcc = true;
|
||||||
|
|
||||||
mailBody = await new Promise((resolve) => {
|
mailBody = await mail.build();
|
||||||
mail.compile().build(async (err: string, result: Buffer) => {
|
|
||||||
resolve(result);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return mailBody.toString('base64').replace(/\+/g, '-').replace(/\//g, '_');
|
return mailBody.toString('base64').replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue