- allow mail from address override
- queue cloud emails
This commit is contained in:
Philipinho
2025-04-07 19:07:10 +01:00
parent 233536314f
commit 06270ff747
6 changed files with 35 additions and 58 deletions

View File

@ -19,18 +19,27 @@ export class MailService {
async sendEmail(message: MailMessage): Promise<void> {
if (message.template) {
// in case this method is used directly. we do not send the tsx template from queue
message.html = await render(message.template, { pretty: true });
message.html = await render(message.template, {
pretty: true,
});
message.text = await render(message.template, { plainText: true });
}
const sender = `${this.environmentService.getMailFromName()} <${this.environmentService.getMailFromAddress()}> `;
let from = this.environmentService.getMailFromAddress();
if (message.from) {
from = message.from;
}
const sender = `${this.environmentService.getMailFromName()} <${from}> `;
await this.mailDriver.sendMail({ from: sender, ...message });
}
async sendToQueue(message: MailMessage): Promise<void> {
if (message.template) {
// transform the React object because it gets lost when sent via the queue
message.html = await render(message.template, { pretty: true });
message.html = await render(message.template, {
pretty: true,
});
message.text = await render(message.template, {
plainText: true,
});