This commit is contained in:
Andris Reinman 2018-09-21 12:44:07 +03:00
parent d8979f158a
commit ed9231d0fd
2 changed files with 21 additions and 1 deletions

View file

@ -137,6 +137,8 @@ class FilterHandler {
let sender = options.sender || '';
let recipient = options.recipient || userData.address;
let filterResults = [];
// create Delivered-To and Return-Path headers
let extraHeader = Buffer.from(['Delivered-To: ' + recipient, 'Return-Path: <' + sender + '>'].join('\r\n') + '\r\n');
@ -473,6 +475,12 @@ class FilterHandler {
err.message
);
} else if (id) {
filterResults.push({
forward: Array.from(forwardTargets)
.map(row => row[0])
.join(','),
'forward-queue-id': id
});
outbound.push(id);
log.silly(
'LMTP',
@ -491,6 +499,7 @@ class FilterHandler {
if (err) {
log.error('LMTP', '%s AUTOREPLYFAIL from=%s to=%s error=%s', prepared.id.toString(), '<>', sender, err.message);
} else if (id) {
filterResults.push({ autoreply: sender, 'autoreply-queue-id': id });
outbound.push(id);
log.silly('LMTP', '%s AUTOREPLYOK id=%s from=%s to=%s', prepared.id.toString(), id, '<>', sender);
}
@ -500,6 +509,8 @@ class FilterHandler {
let err = new Error('Message dropped by policy');
err.code = 'DroppedByPolicy';
filterResults.push({ delete: true });
return callback(null, {
userData,
response: 'Message dropped by policy as ' + prepared.id.toString(),
@ -515,16 +526,19 @@ class FilterHandler {
// positive value is spam
mailboxQueryKey = 'specialUse';
mailboxQueryValue = '\\Junk';
filterResults.push({ spam: true });
}
break;
case 'seen':
if (value) {
flags.push('\\Seen');
filterResults.push({ seen: true });
}
break;
case 'flag':
if (value) {
flags.push('\\Flagged');
filterResults.push({ flagged: true });
}
break;
case 'mailbox':
@ -571,15 +585,21 @@ class FilterHandler {
// make sure we have the updated message structure values
messageOpts.prepared = prepared;
messageOpts.maildata = maildata;
filterResults.push({ encrypted: true });
}
this.messageHandler.add(messageOpts, (err, inserted, info) => {
if (info) {
filterResults.push({ mailbox: info.mailbox && info.mailbox.toString(), id: info.id && info.id.toString() });
}
// push to response list
callback(
null,
{
userData,
response: err ? err : 'Message stored as ' + info.id.toString(),
filterResults,
error: err
},
(!isEncrypted && {

View file

@ -1,6 +1,6 @@
{
"name": "wildduck",
"version": "1.4.13",
"version": "1.4.14",
"description": "IMAP/POP3 server built with Node.js and MongoDB",
"main": "server.js",
"scripts": {