Skip to content

Commit b010bdb

Browse files
author
devZenta
committed
feat(smtpServer): add knock email challenge and notification headers
1 parent 77a032b commit b010bdb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/services/smtpServer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,18 @@ async function initSmtpServer({
9696
'warning',
9797
`💌 - Rejected mail from ${fromAddress} since no token (session: ${session.id}).`,
9898
);
99+
100+
const knockEmail = `${toAddress.split('@')[0]}+knock@${toAddress.split('@')[1]}`;
101+
99102
await sendMail({
100103
from: toAddress,
101104
to: fromAddress,
102105
subject: 'Protected mailbox',
106+
headers: { 'X-SafeSend-Challenge': knockEmail },
103107
text: `Hi!
104108
105109
This mailbox is protected by SafeSend, to send emails to it,
106-
you first need to send a knock email to: ${toAddress.split('@')[0]}+knock@${toAddress.split('@')[1]}
110+
you first need to send a knock email to: ${knockEmail}
107111
108112
Below is a copy of your original email:
109113
Subject: ${subject},
@@ -130,6 +134,7 @@ ${text}
130134
from: fromAddress,
131135
to: toAddress,
132136
subject: "Someone's knocking",
137+
headers: { 'X-SafeSend-KnockUrl': knockLink },
133138
text: `Hi! Someone is knocking, to allow it to send email, click on the link: ${knockLink}`,
134139
});
135140

0 commit comments

Comments
 (0)