Hey,

I have an issue with misformatted vacation emails. Part of the initial mail ends up in the vacation response and the headers of the vacation response end up in the body. Which also leads to the wrong charset being used by (some) MUAs. (Should be utf-8 but the inital mal was ascii only).

I think I narrowed the trigger of the bug down to a long Reference: header line. It only happens if the long line is not the first one.

In the attached example I sent to the mangled mailbox mymailbox@example.com. The sieve rule triggered is this one ("äöü" are only there to demonstrate the breaking charset):

if true
{
vacation :days 7 :addresses ["mymailbox@example.com"] text:
This is an automated reply; I am away and will not be able to reply to you immediately.I will get back to you as soon as I return.äöüß
.
;
}


Christian
--

$ dovecot --version
2.2.13
$ dovecot -n
# 2.2.13: /etc/dovecot/dovecot.conf
# OS: Linux 3.16.0-9-amd64 x86_64 Debian 8.11
disable_plaintext_auth = no
dotlock_use_excl = no
mail_debug = yes
mail_fsync = always
mail_nfs_index = yes
mail_nfs_storage = yes
mail_plugins = acl lazy_expunge listescape mail_log notify
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 imapflags notify
mmap_disable = yes
namespace expunged {
  hidden = yes
  list = no
  location = maildir:~/expunged
  prefix = EXPUNGED.
  separator = /
}
namespace inbox {
  inbox = yes
  location = maildir:~/maildir
  prefix =
  separator = /
}
passdb {
  args = username_format=%n /etc/passwd
  driver = passwd-file
}
plugin {
  acl = vfile
  lazy_expunge = EXPUNGED.
  mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
  mail_log_fields = uid box msgid size
  recipient_delimiter = +
  sieve = ~/sieve/dovecot.sieve
  sieve_dir = ~/sieve/
  sieve_extensions = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date ihave imapflags notify
  sieve_max_redirects = 20
}
protocols = imap pop3 sieve lmtp
service imap-login {
  client_limit = 40
  process_limit = 50
  service_count = 0
  vsz_limit = 512 M
}
service imap {
  process_limit = 2000
  vsz_limit = 512 M
}
service lmtp {
  process_limit = 200
  vsz_limit = 1 G
}
service managesieve-login {
  inet_listener sieve {
    port = 2000
  }
  vsz_limit = 512 M
}
service pop3-login {
  client_limit = 40
  process_limit = 50
  service_count = 0
  vsz_limit = 512 M
}
shutdown_clients = no
ssl_cert = </etc/ssl/certs/cert.crt
ssl_key = </etc/ssl/private/key.key
userdb {
  args = username_format=%n /etc/passwd
  driver = passwd-file
}
verbose_proctitle = yes
protocol imap {
  mail_max_userip_connections = 150
  mail_plugins = acl lazy_expunge listescape mail_log notify imap_acl
}
protocol lmtp {
  lmtp_save_to_detail_mailbox = yes
  mail_plugins = acl lazy_expunge listescape mail_log notify sieve
}