Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

62 lines
1.8 KiB
TypeScript

import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { fromEmailProperty, toEmailProperty } from './descriptions';
import { configureTransport } from './utils';
import { configureWaitTillDate } from '../../../utils/sendAndWait/configureWaitTillDate.util';
import {
createEmailBodyWithN8nAttribution,
createEmailBodyWithoutN8nAttribution,
} from '../../../utils/sendAndWait/email-templates';
import {
createButton,
getSendAndWaitConfig,
getSendAndWaitProperties,
} from '../../../utils/sendAndWait/utils';
export const description: INodeProperties[] = getSendAndWaitProperties(
[fromEmailProperty, toEmailProperty],
'email',
);
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const fromEmail = this.getNodeParameter('fromEmail', 0) as string;
const toEmail = this.getNodeParameter('toEmail', 0) as string;
const config = getSendAndWaitConfig(this);
const buttons: string[] = [];
for (const option of config.options) {
buttons.push(createButton(option.url, option.label, option.style));
}
let htmlBody: string;
if (config.appendAttribution !== false) {
const instanceId = this.getInstanceId();
htmlBody = createEmailBodyWithN8nAttribution(config.message, buttons.join('\n'), instanceId);
} else {
htmlBody = createEmailBodyWithoutN8nAttribution(config.message, buttons.join('\n'));
}
const mailOptions: IDataObject = {
from: fromEmail,
to: toEmail,
subject: config.title,
html: htmlBody,
};
const credentials = await this.getCredentials('smtp');
const transporter = configureTransport(credentials, {});
await transporter.sendMail(mailOptions);
const waitTill = configureWaitTillDate(this);
await this.putExecutionToWait(waitTill);
return [this.getInputData()];
}