Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use multiple user and pass for auth in transport #1161

Open
erfantmi9 opened this issue Apr 17, 2024 · 0 comments
Open

use multiple user and pass for auth in transport #1161

erfantmi9 opened this issue Apr 17, 2024 · 0 comments

Comments

@erfantmi9
Copy link

erfantmi9 commented Apr 17, 2024

Hi.
I have an issue with using multiple user and pass for auth in transport parameter in mailer module.

@Global()
@Module({
  imports: [
    MailerModule.forRootAsync({
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => {
        const MAIL_HOST = configService.get('MAIL_HOST');
        const MAIL_PORT = configService.get('MAIL_PORT');
        const EXPERT_MAIL_USER = configService.get('EXPERT_MAIL_USER');
        const EXPERT_MAIL_PASSWORD = configService.get('EXPERT_MAIL_PASSWORD');
        const path = require('path');

        const templateDir = path.join(process.cwd(), 'email-templates');

        return {
          transport: {
            host: 'smtp.gmail.com',
            port: MAIL_PORT,
            secure: true,
            auth: { user: EXPERT_MAIL_USER, pass: EXPERT_MAIL_PASSWORD },
            // tls: { rejectUnauthorized: true },
          },
          defaults: {
            from: '"Aspedan Expert" <[email protected]>',
          },
          template: {
            dir: templateDir,
            adapter: new HandlebarsAdapter(),
            options: { strict: true },
          },
        };
      },
    }),
  ],
  providers: [EmailService],
  exports: [MailerModule, EmailService],
})
export class EmailModule {}

this is my code and I need to use different values as user and pass for auth.
how can I handle this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant