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,
|
||||
qs,
|
||||
uri: uri || `https://www.googleapis.com${endpoint}`,
|
||||
qsStringifyOptions:{
|
||||
qsStringifyOptions: {
|
||||
arrayFormat: 'repeat',
|
||||
},
|
||||
json: true,
|
||||
|
@ -156,6 +156,7 @@ export async function encodeEmail(email: IEmail) {
|
|||
references: email.reference,
|
||||
subject: email.subject,
|
||||
text: email.body,
|
||||
keepBcc: true,
|
||||
} as IDataObject;
|
||||
if (email.htmlBody) {
|
||||
mailOptions.html = email.htmlBody;
|
||||
|
@ -172,14 +173,15 @@ export async function encodeEmail(email: IEmail) {
|
|||
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) => {
|
||||
mail.compile().build(async (err: string, result: Buffer) => {
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
mailBody = await mail.build();
|
||||
|
||||
return mailBody.toString('base64').replace(/\+/g, '-').replace(/\//g, '_');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue