mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-07 21:55:25 +08:00
filter by delivered-to
This commit is contained in:
parent
5e4777c19e
commit
d487102571
2 changed files with 17 additions and 5 deletions
|
@ -766,27 +766,39 @@ async function checkFilter(filterData, prepared, maildata) {
|
|||
for (let j = prepared.headers.length - 1; j >= 0; j--) {
|
||||
let header = prepared.headers[j];
|
||||
let key = header.key;
|
||||
|
||||
switch (key) {
|
||||
case 'cc':
|
||||
if (!headerFilters.get('cc')) {
|
||||
// match cc against to query
|
||||
case 'delivered-to':
|
||||
if (!headerFilters.get(key)) {
|
||||
// match against "to" query
|
||||
key = 'to';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sender':
|
||||
if (!headerFilters.get(key)) {
|
||||
// match against "from" query
|
||||
key = 'from';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (headerFilters.has(key)) {
|
||||
let check = headerFilters.get(key);
|
||||
let value = (header.value || '').toString();
|
||||
// value should already be lower case though
|
||||
let value = (header.value || '').toString().toLowerCase();
|
||||
|
||||
if (check.isRegex) {
|
||||
if (check.test(value)) {
|
||||
headerMatches.add(key);
|
||||
}
|
||||
} else if (value === check || value.indexOf(check) >= 0) {
|
||||
} else if (value.indexOf(check) >= 0) {
|
||||
headerMatches.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (headerMatches.size < headerFilters.size) {
|
||||
// not enough matches
|
||||
return false;
|
||||
|
|
|
@ -15,7 +15,7 @@ const openpgp = require('openpgp');
|
|||
const parseDate = require('../imap-core/lib/parse-date');
|
||||
|
||||
// index only the following headers for SEARCH
|
||||
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index', 'list-id'];
|
||||
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index', 'list-id', 'delivered-to'];
|
||||
|
||||
openpgp.config.commentstring = 'Plaintext message encrypted by WildDuck Mail Server';
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue