default from email
This commit is contained in:
parent
42d0f302bf
commit
3b3fa2a7de
@ -1,9 +1,9 @@
|
|||||||
import { Provider } from '@nestjs/common';
|
import { FactoryProvider } from '@nestjs/common';
|
||||||
import * as nodemailer from 'nodemailer';
|
import * as nodemailer from 'nodemailer';
|
||||||
import { SMTPConfiguration } from 'src/modules/config/config.interfaces';
|
import { SMTPConfiguration } from 'src/modules/config/config.interfaces';
|
||||||
import { ConfigurationService } from 'src/modules/config/config.service';
|
import { ConfigurationService } from 'src/modules/config/config.service';
|
||||||
|
|
||||||
export const emailProviders: Provider<any>[] = [
|
export const emailProviders: FactoryProvider<nodemailer.Transporter>[] = [
|
||||||
{
|
{
|
||||||
provide: 'EMAIL_TRANSPORT',
|
provide: 'EMAIL_TRANSPORT',
|
||||||
useFactory: async (config: ConfigurationService) =>
|
useFactory: async (config: ConfigurationService) =>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import * as nodemailer from 'nodemailer';
|
import * as nodemailer from 'nodemailer';
|
||||||
|
import { ConfigurationService } from 'src/modules/config/config.service';
|
||||||
import { EmailTemplate } from './email.template';
|
import { EmailTemplate } from './email.template';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -7,6 +8,7 @@ export class EmailService {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject('EMAIL_TRANSPORT')
|
@Inject('EMAIL_TRANSPORT')
|
||||||
private transport: nodemailer.Transporter,
|
private transport: nodemailer.Transporter,
|
||||||
|
private config: ConfigurationService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public async sendEmail(
|
public async sendEmail(
|
||||||
@ -14,7 +16,7 @@ export class EmailService {
|
|||||||
subject: string,
|
subject: string,
|
||||||
text: string,
|
text: string,
|
||||||
html?: string,
|
html?: string,
|
||||||
from = 'no-reply@icynet.eu',
|
from = this.config.get<string>('email.from'),
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return this.transport.sendMail({
|
return this.transport.sendMail({
|
||||||
to,
|
to,
|
||||||
|
Reference in New Issue
Block a user