diff --git a/.changeset/forty-gorillas-kneel.md b/.changeset/forty-gorillas-kneel.md new file mode 100644 index 000000000000..42df0ed8c0e4 --- /dev/null +++ b/.changeset/forty-gorillas-kneel.md @@ -0,0 +1,6 @@ +--- +"@rocket.chat/meteor": patch +"@rocket.chat/apps-engine": patch +--- + +Deprecated the `from` field in the apps email bridge and made it optional, using the server's settings when the field is omitted diff --git a/apps/meteor/app/apps/server/bridges/email.ts b/apps/meteor/app/apps/server/bridges/email.ts index 4c9cb9a93ed6..6d75a4504483 100644 --- a/apps/meteor/app/apps/server/bridges/email.ts +++ b/apps/meteor/app/apps/server/bridges/email.ts @@ -3,6 +3,7 @@ import type { IEmail } from '@rocket.chat/apps-engine/definition/email'; import { EmailBridge } from '@rocket.chat/apps-engine/server/bridges'; import * as Mailer from '../../../mailer/server/api'; +import { settings } from '../../../settings/server'; export class AppEmailBridge extends EmailBridge { constructor(private readonly orch: IAppServerOrchestrator) { @@ -10,7 +11,13 @@ export class AppEmailBridge extends EmailBridge { } protected async sendEmail(email: IEmail, appId: string): Promise { + let { from } = email; + if (!from) { + this.orch.debugLog(`The app ${appId} didn't provide a from address, using the default one.`); + from = String(settings.get('From_Email')); + } + this.orch.debugLog(`The app ${appId} is sending an email.`); - await Mailer.send(email); + await Mailer.send({ ...email, from }); } } diff --git a/packages/apps-engine/src/definition/email/IEmail.ts b/packages/apps-engine/src/definition/email/IEmail.ts index ca81b23e5bcc..27acdc085971 100644 --- a/packages/apps-engine/src/definition/email/IEmail.ts +++ b/packages/apps-engine/src/definition/email/IEmail.ts @@ -1,6 +1,9 @@ export interface IEmail { to: string | string[]; - from: string; + /** + * @deprecated this will be inferred from the settings + */ + from?: string; replyTo?: string; subject: string; html?: string;