mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(core): Add "Sent by n8n" attribution (#7183)
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
This commit is contained in:
@@ -43,6 +43,31 @@ const properties: INodeProperties[] = [
|
||||
placeholder: 'My subject line',
|
||||
description: 'Subject line of the email',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Format',
|
||||
name: 'emailFormat',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Text',
|
||||
value: 'text',
|
||||
},
|
||||
{
|
||||
name: 'HTML',
|
||||
value: 'html',
|
||||
},
|
||||
{
|
||||
name: 'Both',
|
||||
value: 'both',
|
||||
},
|
||||
],
|
||||
default: 'html',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Email Format',
|
||||
name: 'emailFormat',
|
||||
@@ -62,6 +87,11 @@ const properties: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: 'text',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'@version': [2],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Text',
|
||||
@@ -100,6 +130,15 @@ const properties: INodeProperties[] = [
|
||||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||
displayName: 'Append n8n Attribution',
|
||||
name: 'appendAttribution',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to include the phrase “This email was sent automatically with n8n” to the end of the email',
|
||||
},
|
||||
{
|
||||
displayName: 'Attachments',
|
||||
name: 'attachments',
|
||||
@@ -153,6 +192,7 @@ const displayOptions = {
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
type EmailSendOptions = {
|
||||
appendAttribution?: boolean;
|
||||
allowUnauthorizedCerts?: boolean;
|
||||
attachments?: string;
|
||||
ccEmail?: string;
|
||||
@@ -185,6 +225,8 @@ function configureTransport(credentials: IDataObject, options: EmailSendOptions)
|
||||
|
||||
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const nodeVersion = this.getNode().typeVersion;
|
||||
const instanceId = await this.getInstanceId();
|
||||
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
let item: INodeExecutionData;
|
||||
@@ -220,6 +262,32 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
|
||||
mailOptions.html = this.getNodeParameter('html', itemIndex, '');
|
||||
}
|
||||
|
||||
let appendAttribution = options.appendAttribution;
|
||||
if (appendAttribution === undefined) {
|
||||
appendAttribution = nodeVersion >= 2.1;
|
||||
}
|
||||
|
||||
if (appendAttribution) {
|
||||
const attributionText = 'This email was sent automatically with ';
|
||||
const link = `https://n8n.io/?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=${encodeURIComponent(
|
||||
'n8n-nodes-base.emailSend',
|
||||
)}${instanceId ? '_' + instanceId : ''}`;
|
||||
if (emailFormat === 'html' || (emailFormat === 'both' && mailOptions.html)) {
|
||||
mailOptions.html = `
|
||||
${mailOptions.html}
|
||||
<br>
|
||||
<br>
|
||||
---
|
||||
<br>
|
||||
<em>${attributionText}<a href="${link}" target="_blank">n8n</a></em>
|
||||
`;
|
||||
} else {
|
||||
mailOptions.text = `${
|
||||
mailOptions.text
|
||||
}\n\n---\n${attributionText}n8n\n${'https://n8n.io'}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.attachments && item.binary) {
|
||||
const attachments = [];
|
||||
const attachmentProperties: string[] = options.attachments
|
||||
|
||||
Reference in New Issue
Block a user