From b6dae93da20d09895ed3da57d0058181c237f322 Mon Sep 17 00:00:00 2001 From: Anbarasu Date: Fri, 24 May 2024 19:24:18 +0530 Subject: [PATCH] Fix: support name attribute for smtp plugin (#8412) * fix(nocodb): support name parameter for email plugin * fix(nocodb): update placeholders * fix: plugin minor correction * fix: object overwrite other --- packages/nocodb/src/plugins/smtp/SMTP.ts | 13 +++++++++---- packages/nocodb/src/plugins/smtp/index.ts | 23 +++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/nocodb/src/plugins/smtp/SMTP.ts b/packages/nocodb/src/plugins/smtp/SMTP.ts index fc4a5fb4a21..53d2a41e52a 100644 --- a/packages/nocodb/src/plugins/smtp/SMTP.ts +++ b/packages/nocodb/src/plugins/smtp/SMTP.ts @@ -13,6 +13,7 @@ export default class SMTP implements IEmailAdapter { public async init(): Promise { const config = { + name: this.input?.name, host: this.input?.host, port: parseInt(this.input?.port, 10), secure: @@ -23,13 +24,17 @@ export default class SMTP implements IEmailAdapter { typeof this.input?.ignoreTLS === 'boolean' ? this.input?.ignoreTLS : this.input?.ignoreTLS === 'true', - auth: { - user: this.input?.username, - pass: this.input?.password, - }, tls: { rejectUnauthorized: this.input?.rejectUnauthorized, }, + ...(this.input?.username || this.input?.password + ? { + auth: { + ...(this.input?.username ? { user: this.input?.username } : {}), + ...(this.input?.password ? { pass: this.input?.password } : {}), + }, + } + : {}), }; this.transporter = nodemailer.createTransport(config); diff --git a/packages/nocodb/src/plugins/smtp/index.ts b/packages/nocodb/src/plugins/smtp/index.ts index ed51e950539..45c018f966b 100644 --- a/packages/nocodb/src/plugins/smtp/index.ts +++ b/packages/nocodb/src/plugins/smtp/index.ts @@ -7,7 +7,7 @@ import type { XcPluginConfig } from 'nc-plugin'; const config: XcPluginConfig = { builder: SMTPPlugin, title: 'SMTP', - version: '0.0.2', + version: '0.0.3', // icon: 'mdi-email-outline', description: 'SMTP email client', price: 'Free', @@ -18,35 +18,42 @@ const config: XcPluginConfig = { items: [ { key: 'from', - label: 'From', - placeholder: 'eg: admin@run.com', + label: 'From Address', + placeholder: 'admin@run.com', type: XcType.SingleLineText, required: true, }, { key: 'host', - label: 'Host', - placeholder: 'eg: smtp.run.com', + label: 'SMTP Server', + placeholder: 'smtp.run.com', + type: XcType.SingleLineText, + required: true, + }, + { + key: 'name', + label: 'From Domain', + placeholder: 'your-domain.com', type: XcType.SingleLineText, required: true, }, { key: 'port', - label: 'Port', + label: 'SMTP Port', placeholder: 'Port', type: XcType.SingleLineText, required: true, }, { key: 'secure', - label: 'Secure', + label: 'Use Secure Connection', placeholder: 'Secure', type: XcType.Checkbox, required: false, }, { key: 'ignoreTLS', - label: 'Ignore TLS', + label: 'Ignore TLS Errors', placeholder: 'Ignore TLS', type: XcType.Checkbox, required: false,