VitNode

SMTP

How to integrete SMTP provider to send emails.

Install package

pnpm i vitnode-backend-email-smtp --filter backend

.env file

Add the following to your .env file:

EMAIL_SMTP_HOST={your_host}
EMAIL_SMTP_PORT={your_port}
EMAIL_SMTP_SECURE={true/false}
EMAIL_SMTP_USER={your_user}
EMAIL_SMTP_FROM={your_from_email}
EMAIL_SMTP_PASSWORD={your_password}

Provide config

Provide emailResend to VitNodeCoreModule:

apps/backend/src/app.module.ts
import { Module } from '@nestjs/common';
import { VitNodeCoreModule } from 'vitnode-backend';
import { emailSMTP } from 'vitnode-backend-email-smtp'; 
 
import { DATABASE_ENVS, schemaDatabase } from './database/config';
import { DatabaseModule } from './database/database.module';
import { PluginsModule } from './plugins/plugins.module';
 
@Module({
  imports: [
    VitNodeCoreModule.register({
      database: {
        config: DATABASE_ENVS,
        schemaDatabase,
      },

      email: emailSMTP({

        host: process.env.EMAIL_SMTP_HOST, 
        port: process.env.EMAIL_SMTP_PORT, 
        secure: process.env.EMAIL_SMTP_SECURE === 'true', 
        user: process.env.EMAIL_SMTP_USER, 
        password: process.env.EMAIL_SMTP_PASSWORD, 
        from: process.env.EMAIL_SMTP_FROM, 

      }),
    }),
    DatabaseModule,
    PluginsModule,
  ],
})
export class AppModule {}

On this page