Skip to content

Commit

Permalink
Notify via email about rejected messages to the forwarding address (f…
Browse files Browse the repository at this point in the history
…ixes #41)
  • Loading branch information
zieren committed Jun 29, 2023
1 parent b617eac commit 2e68184
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,13 +887,23 @@ async function processNewEmail() {
}

// Prevent accidental impersonation by allowing only known senders in the From:.
if (!parsedMessage.from || !parsedMessage.from.value.length) {
LOG.warn('Rejected incoming email without From:');
continue;
let rejectedFrom = null;
if (!parsedMessage.from || !parsedMessage.from.value.length) { // never allowed
rejectedFrom = '';
} else if (!CONFIG.options.incomingEmail.allowForwardingFrom.includes( // maybe not allowed
// Assume just one element in the From: header, for simplicity.
parsedMessage.from.value[0].address.toLowerCase())) {
rejectedFrom = parsedMessage.from.text;
}
if (!CONFIG.options.incomingEmail.allowForwardingFrom.includes(
parsedMessage.from.value[0].address.toLowerCase())) {
LOG.warn(`Rejected incoming email from "${parsedMessage.from.text}"`);
if (rejectedFrom !== null) {
LOG.warn(`Rejecting incoming email from "${rejectedFrom}"`);
INBOUND.push({
email: buildEmail('Fehlerteufel', 'Nachricht von fremdem Absender ignoriert', {
text: `Nachricht von "${rejectedFrom}" an ` +
`${CONFIG.options.incomingEmail.forwardingAddress} wurde ignoriert.\n\n` +
'ACHTUNG: Diese Adresse sollte nicht veröffentlicht werden!',}),
ok: () => {}
});
continue;
}

Expand Down

0 comments on commit 2e68184

Please sign in to comment.