nest-modules / mailer

📨 A mailer module for Nest framework (node.js)
https://nest-modules.github.io/mailer/
MIT License
836 stars 174 forks source link

sendEmail hangs indefinitely after migrating 1.8.1 to 1.9.1+ #1216

Open radulescuandrew opened 2 months ago

radulescuandrew commented 2 months ago

Describe the bug After bumping from version 1.8.1 to 1.9.1, the emails are stuck in sendMail on local but works in a staging environment.

To Reproduce Steps to reproduce the behavior:

  1. Bump from 1.8.1 to 1.9.1
  2. Send any email

Expected behavior The email is sent.

Versions:

Additional context

The config stays the same as on 1.8.1, nothing changed.

createMailerOptions(): MailerOptions {
    return {
      transport: {
        host: this.configService.get('MAIL_HOST'),
        port: +this.configService.get('MAIL_PORT'),
        ignoreTLS: false, 
        secure: false, 
        auth: {
          user: this.configService.get('MAIL_USER'),
          pass: this.configService.get('MAIL_PASS'),
        },
      },
      defaults: {
        from: '"No Reply" <no-reply@localhost>',
      },
      preview: true,
      template: {
        dir: __dirname + '/../../mail/templates',
        adapter: new HandlebarsAdapter({ asset_url: this.createAssetUrl }),
        options: {
          strict: true,
        },
      },
      options: {
        partials: {
          dir: __dirname + '/../../mail/templates/' + 'partials',
          options: {
            strict: true,
          },
        },
      },
    };
  }

✅ The email is sent if the template is removed ❌ otherwise the following function never errors out or return: this.mailerService.sendMail(mailOptions);

There is any major change between 1.8.1 and 1.9.1 which I'm missing?

Later edit:

With debug: true is shows the following:

[2024-07-09 13:33:19] DEBUG Sending mail using SMTP/6.7.5[client:6.7.5]
[2024-07-09 13:33:19] DEBUG Using 1 plugins for compile
[2024-07-09 13:33:19] DEBUG Using 1 plugins for stream

Much appreciated!

radulescuandrew commented 1 month ago

Removing preview: true fixed my issue.

On version 1.8.1 it was working just fine with the preview active.

Close the issue if you consider it a non issue or you can't reproduce. Thanks!