Skip to content

Commit

Permalink
fix(platform-server): fix email sender name
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Sep 27, 2022
1 parent 7129578 commit bfdde9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test.afterEach(() => {
createTransportStub.restore()
})

test('missing smtp option', async (t) => {
test.serial('missing smtp option', async (t) => {
t.context.module = await Test.createTestingModule({
imports: [
EmailModule,
Expand All @@ -64,7 +64,7 @@ test('missing smtp option', async (t) => {
t.is(sendMailStub.callCount, 0)
})

test('send mail', async (t) => {
test.serial('send mail', async (t) => {
t.context.module = await Test.createTestingModule({
imports: [
EmailModule,
Expand All @@ -80,5 +80,5 @@ test('send mail', async (t) => {
await email.sendMail(testMail)
t.true(createTransportStub.calledOnce)
t.is(createTransportStub.getCall(0).args[0].host, testOptions.smtp.host)
t.true(sendMailStub.calledOnceWith(testMail))
t.true(sendMailStub.calledOnceWith(sinon.match(testMail)))
})
6 changes: 3 additions & 3 deletions packages/platform-server/src/modules/email/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { SendMailOptions } from './types'
export class EmailService {
private readonly transporter: nodemailer.Transporter | null = null

constructor(private readonly logger: Logger, config: Config) {
constructor(private readonly logger: Logger, private readonly config: Config) {
const email = config.email
const { smtp: smtpOption, from } = email
if (!smtpOption.host) {
Expand All @@ -41,7 +41,7 @@ export class EmailService {
user: smtpOption.auth.user, // generated ethereal user
pass: smtpOption.auth.pass, // generated ethereal password
},
from: `"${from.name}" <${from.address}>`,
from: from,
})
}

Expand All @@ -50,7 +50,7 @@ export class EmailService {
return false
}

await this.transporter?.sendMail(options)
await this.transporter?.sendMail({ ...options, from: this.config.email.from })

return true
}
Expand Down

0 comments on commit bfdde9e

Please sign in to comment.