default from email

This commit is contained in:
Evert Prants 2022-09-09 17:51:15 +03:00
parent 42d0f302bf
commit 3b3fa2a7de
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 5 additions and 3 deletions

View File

@ -1,9 +1,9 @@
import { Provider } from '@nestjs/common';
import { FactoryProvider } from '@nestjs/common';
import * as nodemailer from 'nodemailer';
import { SMTPConfiguration } from 'src/modules/config/config.interfaces';
import { ConfigurationService } from 'src/modules/config/config.service';
export const emailProviders: Provider<any>[] = [
export const emailProviders: FactoryProvider<nodemailer.Transporter>[] = [
{
provide: 'EMAIL_TRANSPORT',
useFactory: async (config: ConfigurationService) =>

View File

@ -1,5 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import * as nodemailer from 'nodemailer';
import { ConfigurationService } from 'src/modules/config/config.service';
import { EmailTemplate } from './email.template';
@Injectable()
@ -7,6 +8,7 @@ export class EmailService {
constructor(
@Inject('EMAIL_TRANSPORT')
private transport: nodemailer.Transporter,
private config: ConfigurationService,
) {}
public async sendEmail(
@ -14,7 +16,7 @@ export class EmailService {
subject: string,
text: string,
html?: string,
from = 'no-reply@icynet.eu',
from = this.config.get<string>('email.from'),
): Promise<any> {
return this.transport.sendMail({
to,