Greg Rivers
2014-Jan-06 21:27 UTC
[Dovecot] Dovecot LMTP does not pass envelope recipient +detail to sieve
I found this[1] thread that describes the same problem with dovecot-LDA, but the solution (add X-Original-To: header) has no effect with LMTP. My sendmail LMTP configuration: FEATURE(`local_lmtp',`[IPC]',`FILE /var/run/dovecot/lmtp') Sendmail's address test indicates that sendmail is providing user+detail to LMTP (see below). Except for this problem, dovecot, LMTP, and sieve are all working perfectly. Is there something I'm missing, or is this a bug? [1] http://dovecot.org/pipermail/dovecot/2012-July/136987.htm Script started on Sun Jan 5 23:25:04 2014 $ doveconf -n # 2.2.9: /usr/local/etc/dovecot/dovecot.conf # OS: FreeBSD 9.2-STABLE amd64 auth_verbose = yes mail_debug = yes mail_location = mdbox:~/.mdbox mail_plugins = " quota" managesieve_notify_capability = mailto managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave editheader vnd.dovecot.debug vnd.dovecot.duplicate imapflags notify vnd.dovecot.pipe vnd.dovecot.filter vnd.dovecot.execute namespace inbox { inbox = yes location mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { args = %s driver = pam } plugin { quota = fs:%n@%{hostname} %h %Us %{pid}: quota_warning = storage=95%% quota-warning 95 %u quota_warning2 = storage=80%% quota-warning 80 %u sieve = ~/.dovecot.sieve sieve_dir = ~/sieve sieve_execute_bin_dir = ~/sieve/sieve-execute sieve_execute_socket_dir = sieve-execute sieve_extensions = +notify +imapflags +editheader +vnd.dovecot.duplicate +vnd.dovecot.pipe +vnd.dovecot.filter +vnd.dovecot.execute +vnd.dovecot.debug sieve_filter_bin_dir = ~/sieve/sieve-filter sieve_filter_socket_dir = sieve-filter sieve_global_dir = /usr/local/etc/dovecot/sieve sieve_max_actions = 0 sieve_max_redirects = 16 sieve_max_script_size = 0 sieve_pipe_bin_dir = ~/sieve/sieve-pipe sieve_pipe_socket_dir = sieve-pipe sieve_plugins = sieve_extprograms } postmaster_address = postmaster at tharned.org protocols = imap lmtp sieve quota_full_tempfail = yes service quota-warning { executable = script /usr/local/bin/quota-warning.sh unix_listener quota-warning { user = dovecot } user = dovecot } ssl_cert = </etc/ssl/certs/dovecot.pem ssl_key = </etc/ssl/private/dovecot.pem userdb { driver = passwd } verbose_proctitle = yes protocol lmtp { mail_plugins = " quota sieve" } protocol lda { mail_plugins = " quota sieve" } protocol imap { mail_max_userip_connections = 100 mail_plugins = " quota imap_quota" } $ sendmail -bt ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address>> =Mmailer 0 (prog): P=/bin/sh S=EnvFromL/HdrFromL R=EnvToL/HdrToL M=0 U=-1:-1 F=9DFMeloqsu L=0 E=\n T=X-Unix/X-Unix/X-Unix r=100 A=sh -c $u mailer 1 (*file*): P=[FILE] S=parse/parse R=parse/parse M=0 U=-1:-1 F=9DEFMPloqsu L=0 E=\n T=X-Unix/X-Unix/X-Unix r=100 A=FILE $u mailer 2 (*include*): P=/dev/null S=parse/parse R=parse/parse M=0 U=-1:-1 F=su L=0 E=\n T=<undefined>/<undefined>/<undefined> r=100 A=INCLUDE $u mailer 3 (local): P=[IPC] S=EnvFromSMTP/HdrFromL R=EnvToL/HdrToL M=0 U=-1:-1 F=/59:@ADFMPSXlmnqswz| L=0 E=\r\n T=DNS/RFC822/SMTP r=100 A=FILE /var/run/dovecot/lmtp mailer 4 (smtp): P=[IPC] S=EnvFromSMTP/HdrFromSMTP R=EnvToSMTP/EnvToSMTP M=0 U=-1:-1 F=DFMXmu L=990 E=\r\n T=DNS/RFC822/SMTP r=100 A=TCP $h mailer 5 (esmtp): P=[IPC] S=EnvFromSMTP/HdrFromSMTP R=EnvToSMTP/EnvToSMTP M=0 U=-1:-1 F=DFMXamu L=990 E=\r\n T=DNS/RFC822/SMTP r=100 A=TCP $h mailer 6 (smtp8): P=[IPC] S=EnvFromSMTP/HdrFromSMTP R=EnvToSMTP/EnvToSMTP M=0 U=-1:-1 F=8DFMXmu L=990 E=\r\n T=DNS/RFC822/SMTP r=100 A=TCP $h mailer 7 (dsmtp): P=[IPC] S=EnvFromSMTP/HdrFromSMTP R=EnvToSMTP/EnvToSMTP M=0 U=-1:-1 F=%DFMXamu L=990 E=\r\n T=DNS/RFC822/SMTP r=100 A=TCP $h mailer 8 (relay): P=[IPC] S=EnvFromSMTP/HdrFromSMTP R=MasqSMTP/MasqSMTP M=0 U=-1:-1 F=8DFMXamu L=2040 E=\r\n T=DNS/RFC822/SMTP r=100 A=TCP $h> /try local gcr+DeTaIl at tharned.orgTrying envelope recipient address gcr+DeTaIl at tharned.org for mailer local canonify input: gcr + DeTaIl @ tharned . org Canonify2 input: gcr + DeTaIl < @ tharned . org > Canonify2 returns: gcr + DeTaIl < @ tharned . org . > canonify returns: gcr + DeTaIl < @ tharned . org . > 2 input: gcr + DeTaIl < @ tharned . org . > 2 returns: gcr + DeTaIl < @ tharned . org . > EnvToL input: gcr + DeTaIl < @ tharned . org . > EnvToL returns: gcr + DeTaIl final input: gcr + DeTaIl final returns: gcr + DeTaIl Rcode = 0, addr = gcr+DeTaIl> ^D$ cat .dovecot.sieve require ["envelope", "subaddress", "variables", "vnd.dovecot.debug"]; if envelope :matches "to" "*" { set "to" "${1}"; } if envelope :user :matches "to" "*" { set "user" "${1}"; } if envelope :detail :matches "to" "*" { set "detail" "${1}"; } if envelope :matches "from" "*" { set "from" "${1}"; } debug_log "EnvelopeTo=${to}, EnvelopeFrom=${from}"; debug_log "EnvelopeToUser=${user}, EnvelopeToDetail=${detail}"; $ telnet localhost smtp Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 tharned.org ESMTP Sendmail 8.14.7/8.14.7; Sun, 5 Jan 2014 23:56:22 -0600 (CST) mail from:<gcr at tharned.org> 250 2.1.0 <gcr at tharned.org>... Sender ok rcpt to:<gcr+DeTaIl at tharned.org> 250 2.1.5 <gcr+DeTaIl at tharned.org>... Recipient ok data 354 Enter mail, end with "." on a line by itself . 250 2.0.0 s065uMYM069381 Message accepted for delivery quit 221 2.0.0 tharned.org closing connection Connection closed by foreign host. $ tail -4 .dovecot.sieve.log sieve: info: started log at Jan 05 23:57:21. main script: line 5: info: DEBUG: EnvelopeTo=gcr, EnvelopeFrom=gcr at tharned.org. main script: line 9: info: DEBUG: EnvelopeToUser=gcr, EnvelopeToDetail=. info: msgid=<201401060557.s065uMYM069381 at tharned.org>: stored mail into mailbox 'INBOX'. $ exit Script done on Sun Jan 5 23:57:55 2014 -- Greg Rivers
Greg Rivers
2014-Jan-08 02:20 UTC
[Dovecot] Dovecot LMTP does not pass envelope recipient +detail to sieve
On Mon, 6 Jan 2014, I wrote:> I found this[1] thread that describes the same problem with dovecot-LDA, > but the solution (add X-Original-To: header) has no effect with LMTP. > > My sendmail LMTP configuration: > FEATURE(`local_lmtp',`[IPC]',`FILE /var/run/dovecot/lmtp') > > Sendmail's address test indicates that sendmail is providing user+detail > to LMTP (see below). Except for this problem, dovecot, LMTP, and sieve > are all working perfectly. Is there something I'm missing, or is this a > bug? > > [1] http://dovecot.org/pipermail/dovecot/2012-July/136987.htm >It seems I was mistaken. By tracing the LMTP session between dovecot and sendmail I found that sendmail does _not_ include the +detail in RCPT TO:. I also determined that dovecot LMTP will in fact extract the +detail from a X-Original-To: header, but only if one defines lda_original_recipient_header. So for the archives, to get sieve's "envelope :detail ..." working with sendmail and dovecot LMTP, do the following: 1) Add "lda_original_recipient_header = X-Original-To" to 15-lda.conf 2) Add the following rule to sendmail.mc to add a X-Original-To: header to every message: LOCAL_CONFIG H?${u}?X-Original-To: $u -- Greg Rivers