Add Delivered-To header to received messages

Postfix, after expanding the alias, is not transmitting the original
envelope recipient email address to dovecot and cannot record it in a
Received: header.

The LMTP DSN extension allows postfix to specify an ORCPT= parameter to
the "RCPT TO:" line (in postfix src/smtp/smtp_proto.c). However, dovecot
does not support the DNS extension on the LMTP endpoint. It has
preliminary support of the ORCPT parameter in latest versions but is is
disabled and not working.

The solution taken was to add a sieve script to parse the Received:
header written by postfix and parse the original RCPT TO address from
it. Then add the header through the "editheader" sieve extension. Later
sieve scripts can take this header to perform further filtering.
master
Mildred Ki'Lya 7 years ago
parent 52bad80af8
commit 649a4fc9cf

@ -138,7 +138,7 @@ service managesieve {
plugin { plugin {
sieve = file:~/sieve;active=~/.dovecot.sieve sieve = file:~/sieve;active=~/.dovecot.sieve
sieve_plugins = sieve_extdata sieve_imapsieve sieve_extprograms sieve_plugins = sieve_extdata sieve_imapsieve sieve_extprograms
sieve_global_extensions = +vnd.dovecot.extdata +spamtest +spamtestplus +vnd.dovecot.execute sieve_global_extensions = +vnd.dovecot.extdata +spamtest +spamtestplus +vnd.dovecot.execute +editheader
sieve_before = /var/lib/dovecot/before.sieve sieve_before = /var/lib/dovecot/before.sieve
sieve_default = /var/lib/dovecot/default.sieve sieve_default = /var/lib/dovecot/default.sieve
sieve_after = /var/lib/dovecot/after.sieve sieve_after = /var/lib/dovecot/after.sieve

@ -11,6 +11,14 @@ require "comparator-i;ascii-numeric";
require "vnd.dovecot.extdata"; require "vnd.dovecot.extdata";
require "vnd.dovecot.execute"; require "vnd.dovecot.execute";
require "spamtestplus"; require "spamtestplus";
require "editheader";
require "index";
if header :index 2 :matches "Received" "from * by * for <*>; *"
{
deleteheader "Delivered-To";
addheader "Delivered-To" "<${3}>";
}
if allof (string :is "${extdata.spam_enabled}" "1", if allof (string :is "${extdata.spam_enabled}" "1",
spamtest :percent :value "gt" :comparator "i;ascii-numeric" "${extdata.spam_threshold}") spamtest :percent :value "gt" :comparator "i;ascii-numeric" "${extdata.spam_threshold}")

Loading…
Cancel
Save