mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2026-01-08 18:59:36 +01:00
[Feat]: Add blacklisted Sender list
Allows admin to stop receiving mails from specific senders, for example to prevent account verification emails to arrive
This commit is contained in:
parent
985c36920b
commit
49e4e6eaf9
4 changed files with 21 additions and 5 deletions
|
|
@ -10,6 +10,7 @@ EMAIL_PURGE_CONVERT=true # Convert to hig
|
|||
# --- Example emails to keep clean ---
|
||||
EMAIL_EXAMPLE_ACCOUNT="example@48hr.email" # example email to preserve
|
||||
EMAIL_EXAMPLE_UIDS=[1,2,3] # example UIDs to preserve
|
||||
EMAIL_BLACKLISTED_SENDERS=[] # List of email addresses to block (Useful to prevent account generators) ["noreply@facebook.com", "noreply@amazon.com"]
|
||||
|
||||
# --- IMAP CONFIGURATION ---
|
||||
IMAP_USER="user@example.com" # IMAP username
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ const config = {
|
|||
examples: {
|
||||
account: parseValue(process.env.EMAIL_EXAMPLE_ACCOUNT),
|
||||
uids: parseValue(process.env.EMAIL_EXAMPLE_UIDS)
|
||||
}
|
||||
},
|
||||
blacklistedSenders: parseValue(process.env.EMAIL_BLACKLISTED_SENDERS) || []
|
||||
},
|
||||
|
||||
imap: {
|
||||
|
|
@ -84,4 +85,4 @@ if (!config.email.domains.length) {
|
|||
|
||||
debug(`Configuration validated successfully: ${config.email.domains.length} domains, IMAP host: ${config.imap.host}`)
|
||||
|
||||
module.exports = config;
|
||||
module.exports = config;
|
||||
|
|
|
|||
|
|
@ -144,6 +144,20 @@ class MailProcessingService extends EventEmitter {
|
|||
|
||||
onNewMail(mail) {
|
||||
debug('onNewMail called for:', mail.to)
|
||||
|
||||
// Check if sender is blacklisted
|
||||
const senderAddress = mail.from && mail.from[0] && mail.from[0].address
|
||||
if (senderAddress && this.config.email.blacklistedSenders.length > 0) {
|
||||
const isBlacklisted = this.config.email.blacklistedSenders.some(blocked =>
|
||||
blocked.toLowerCase() === senderAddress.toLowerCase()
|
||||
)
|
||||
if (isBlacklisted) {
|
||||
debug(`Blacklisted sender detected: ${senderAddress}, deleting UID ${mail.uid}`)
|
||||
this.imapService.deleteSpecificEmail(mail.uid)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (this.initialLoadDone) {
|
||||
// For now, only log messages if they arrive after the initial load
|
||||
debug('New mail for', mail.to[0])
|
||||
|
|
@ -210,4 +224,4 @@ class MailProcessingService extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = MailProcessingService
|
||||
module.exports = MailProcessingService
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "48hr.email",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"private": false,
|
||||
"description": "48hr.email is your favorite open-source tempmail client.",
|
||||
"keywords": [
|
||||
|
|
@ -78,4 +78,4 @@
|
|||
]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue