Skip to content

Commit

Permalink
smtp/client: filter duplicate message recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
zackschuster committed May 26, 2020
1 parent a9d6878 commit 265b88a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions smtp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ export class Client {
} as MessageStack;

if (message.header.cc) {
stack.to = stack.to.concat(addressparser(message.header.cc));
stack.to = stack.to.concat(
addressparser(message.header.cc).filter(
(x) => stack.to.some((y) => y.address === x.address) === false
)
);
}

if (message.header.bcc) {
stack.to = stack.to.concat(addressparser(message.header.bcc));
stack.to = stack.to.concat(
addressparser(message.header.bcc).filter(
(x) => stack.to.some((y) => y.address === x.address) === false
)
);
}

if (
Expand Down
2 changes: 2 additions & 0 deletions test/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ test.cb('simple text message', (t) => {
subject: 'this is a test TEXT message from emailjs',
from: '[email protected]',
to: '[email protected]',
cc: '[email protected]',
bcc: '[email protected]',
text: 'hello friend, i hope this message finds you well.',
'message-id': 'this is a special id',
};
Expand Down

0 comments on commit 265b88a

Please sign in to comment.