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.