0

I am using nodemailer and handlebars templates in nest.js for mailing.

Everything works fine with gmail. But for outlook, mails are getting received in 'Junk' folder.

Mailer.module.ts:

MailerModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: async (configService: ConfigService) => ({
    transport: {
      host: 'smtp.office365.com',
      port: 587,
      requireTLS: true,
      secure: false,
      auth: {
        user: *******@gmail.com,
        pass: *****************,
      },
    },
    template: {
      dir: join(__dirname, '../../../src/templates'),
      adapter: new HandlebarsAdapter(),
      options: {
        strict: true,
      },
    },
  }),
  inject: [ConfigService],
})

Mailer.service.ts:

return this.mailService.sendEmail({
    to: <some-outlook-mail-id>,
    from: *******@gmail.com // same used in auth
    subject: 'Test mail',
    someUrl: 'https://google.co.in',
    template: 'greetings',
  });

greetings.hbs:

<h2>Dear User</h2>
<p>Click <a href={{someUrl}}>here</a></p>

It happens only while sending links. For normal html content, mails are coming in outlook inbox.

Need some valuable help to resolve this.

1 Answers1

0

This usually is not related to the software that you're using. Receiving email servers take a look at the given mail content (and many more factors) and then decide whether your mail is "junk".

Assuming you only send the given template, it is more likely that you are a spammer phishing for users input than having a genuine interest in delivering valuable content.

More information can be taken from this listing: Bettina Specht - "Why are my emails going to spam".

David
  • 184
  • 8