Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IMessage } from '../email/email.interface.js';
import { EmailConfigService } from '../email-config/email-config.service.js';
import { IEmailTransporterInterface } from './email-transporter.interface.js';
import { Injectable } from '@nestjs/common';
import { isSaaS } from '../../../helpers/app/is-saas.js';
@Injectable()
export class EmailTransporterService implements IEmailTransporterInterface {
private transporter: nodemailer.Transporter;
Expand All @@ -12,8 +13,9 @@ export class EmailTransporterService implements IEmailTransporterInterface {
}

public async transportEmail(mail: IMessage): Promise<SMTPTransport.SentMessageInfo> {
const formattedFrom = isSaaS() ? this.formatEmailAddress(mail.from) : mail.from;
return await this.transporter.sendMail({
from: mail.from,
from: formattedFrom,
to: mail.to,
subject: mail.subject,
text: mail.text,
Expand All @@ -25,4 +27,9 @@ export class EmailTransporterService implements IEmailTransporterInterface {
const transportConfig = this.emailConfigService.getEmailServiceConfig();
return nodemailer.createTransport(transportConfig);
}

private formatEmailAddress(email: string): string {
const defaultName = 'Rocketadmin.com';
return `${defaultName} <${email}>`;
}
}
Loading