Skip to content

Commit e84f245

Browse files
authored
Merge pull request #8 from BrewInteractive/feature/add-attachment-for-smtp-service
feat: add attachment for smtp service
2 parents 0d69483 + 5e7412f commit e84f245

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/email/providers/smtp/smtp-email.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('SmtpEmailService', () => {
4949
html: mockEmail.content,
5050
cc: mockEmail.cc,
5151
bcc: mockEmail.bcc,
52+
attachments: mockEmail.attachments,
5253
});
5354
});
5455

@@ -57,7 +58,7 @@ describe('SmtpEmailService', () => {
5758
const mockEmail = MockFactory(EmailFixture).one();
5859
delete mockEmail.cc;
5960
delete mockEmail.bcc;
60-
61+
delete mockEmail.attachments;
6162
jest
6263
.spyOn(emailService['smtpClient'], 'sendMail')
6364
.mockResolvedValue(Promise.resolve(null));
@@ -73,6 +74,7 @@ describe('SmtpEmailService', () => {
7374
html: mockEmail.content,
7475
bcc: [],
7576
cc: [],
77+
attachments: [],
7678
});
7779
});
7880
});

src/email/providers/smtp/smtp-email.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export class SmtpEmailService extends EmailService {
3131
html: email.content,
3232
cc: email.cc ?? [],
3333
bcc: email.bcc ?? [],
34+
attachments: email.attachments?.map(attachment => ({
35+
content: attachment.content,
36+
filename: attachment.filename,
37+
type: attachment.type,
38+
disposition: attachment.disposition ?? 'attachment',
39+
})) ?? []
3440
});
3541
}
3642
}

0 commit comments

Comments
 (0)