Hi,
to get a 'Delivered-to' header based on ORCPT, I wrote a patch
(attached) to force Dovecot lmtp to advertise DSN after a LHLO command.
In this way, Postfix add an ORCPT to the RCTP command
(http://postfix.1071664.n5.nabble.com/pipe-flags-vs-lmtp-td11587.html#a11596).
Be carefully: in this way DSN notification is broken, but they were
broken in any case at the time I wrote the patch (read the entire post
linked above).
The first patch is for Dovecot 2.2.x: after apply, you cannot disable
the DSN advertisement. The other is for Dovecot 2.3.0: you can
enable/disable the advertisement using the new bool parameter
'lmtp_lhlo_dsn'.
I'm using it for the past two years, without any problem.
Thanks,
Marco
On 2018-08-07 11:48, Tom Sommer wrote:
> On 2015-09-02 22:01, Peer Heinlein wrote:
>> Since
>>
>> http://dovecot.org/pipermail/dovecot-cvs/2014-November/025241.html
>>
>> Dovecot's LMTP does support ORCPT.
>>
>> Is it possible to set X-Original-To-Header based on that ORCPT?
>
> Any news or response on this? I too am in need of this header being
> passed and saved correctly.
>
> Thanks.
>
> --
> Tom
>
--
Marco Giunta - ITCS SysAdmin
Via Bonomea, 265
34136 - Trieste, Italy
Tel: +39-040-3787-503
Fax: +39-040-3787-244
--- dovecot-2.2.24/src/lmtp/commands.c.orig 2016-04-26 15:01:21.000000000 +0200
+++ dovecot-2.2.24/src/lmtp/commands.c 2017-02-16 16:01:39.091220376 +0100
@@ -82,7 +82,8 @@
client_send_line(client, "250-XCLIENT ADDR PORT TTL TIMEOUT");
client_send_line(client, "250-8BITMIME");
client_send_line(client, "250-ENHANCEDSTATUSCODES");
- client_send_line(client, "250 PIPELINING");
+ client_send_line(client, "250-PIPELINING");
+ client_send_line(client, "250 DSN");
i_free(client->lhlo);
client->lhlo = i_strdup(str_c(domain));
@@ -200,6 +201,11 @@
client->state.mail_body_7bit = TRUE;
else if (strcasecmp(*argv, "BODY=8BITMIME") == 0)
client->state.mail_body_8bitmime = TRUE;
+ /* Skip unsupported DSN parameters */
+ else if (strncasecmp(*argv, "RET=", 4) == 0)
+ continue;
+ else if (strncasecmp(*argv, "ENVID=", 6) == 0)
+ continue;
else {
client_send_line(client,
"501 5.5.4 Unsupported options");
@@ -638,9 +644,12 @@
argv = t_strsplit(params, " ");
for (; *argv != NULL; argv++) {
- if (strncasecmp(*argv, "ORCPT=", 6) == 0) {
+ if (strncasecmp(*argv, "ORCPT=", 6) == 0)
rcpt->params.dsn_orcpt = parse_xtext(client, *argv + 6);
- } else {
+ /* Skip unsupported DSN parameter */
+ else if (strncasecmp(*argv, "NOTIFY=", 7) == 0)
+ continue;
+ else {
client_send_line(client, "501 5.5.4 Unsupported options");
return 0;
}
diff -up dovecot-2.3.0/src/lmtp/client.c.orig dovecot-2.3.0/src/lmtp/client.c
--- dovecot-2.3.0/src/lmtp/client.c.orig 2018-01-05 07:45:36.000000000 +0100
+++ dovecot-2.3.0/src/lmtp/client.c 2018-01-16 08:55:49.437006465 +0100
@@ -151,6 +151,8 @@ struct client *client_create(int fd_in,
SMTP_CAPABILITY_ENHANCEDSTATUSCODES |
SMTP_CAPABILITY_8BITMIME |
SMTP_CAPABILITY_CHUNKING;
+ if (client->lmtp_set->lmtp_lhlo_dsn)
+ lmtp_set.capabilities |= SMTP_CAPABILITY_DSN;
if (!conn->ssl && master_service_ssl_is_enabled(master_service))
lmtp_set.capabilities |= SMTP_CAPABILITY_STARTTLS;
lmtp_set.hostname = client->unexpanded_lda_set->hostname;
diff -up dovecot-2.3.0/src/lmtp/lmtp-settings.c.orig dovecot-2.3.0/src/lmtp/lmtp-settings.c
--- dovecot-2.3.0/src/lmtp/lmtp-settings.c.orig 2018-01-05 07:45:36.000000000 +0100
+++ dovecot-2.3.0/src/lmtp/lmtp-settings.c 2018-01-16 08:53:13.513920390 +0100
@@ -62,6 +62,7 @@ static const struct setting_define lmtp_
DEF(SET_BOOL, lmtp_proxy),
DEF(SET_BOOL, lmtp_save_to_detail_mailbox),
DEF(SET_BOOL, lmtp_rcpt_check_quota),
+ DEF(SET_BOOL, lmtp_lhlo_dsn),
DEF(SET_UINT, lmtp_user_concurrency_limit),
DEF(SET_ENUM, lmtp_hdr_delivery_address),
DEF(SET_STR_VARS, login_greeting),
@@ -74,6 +75,7 @@ static const struct lmtp_settings lmtp_d
.lmtp_proxy = FALSE,
.lmtp_save_to_detail_mailbox = FALSE,
.lmtp_rcpt_check_quota = FALSE,
+ .lmtp_lhlo_dsn = FALSE,
.lmtp_user_concurrency_limit = 0,
.lmtp_hdr_delivery_address = "final:none:original",
.login_greeting = PACKAGE_NAME" ready.",
diff -up dovecot-2.3.0/src/lmtp/lmtp-settings.h.orig dovecot-2.3.0/src/lmtp/lmtp-settings.h
--- dovecot-2.3.0/src/lmtp/lmtp-settings.h.orig 2018-01-05 07:45:36.000000000 +0100
+++ dovecot-2.3.0/src/lmtp/lmtp-settings.h 2018-01-16 08:57:18.505887547 +0100
@@ -16,6 +16,7 @@ struct lmtp_settings {
bool lmtp_proxy;
bool lmtp_save_to_detail_mailbox;
bool lmtp_rcpt_check_quota;
+ bool lmtp_lhlo_dsn;
unsigned int lmtp_user_concurrency_limit;
const char *lmtp_hdr_delivery_address;
const char *login_greeting;