--- dovecot-2.2.33.2/src/lib-mail/mail-user-hash.c 2017-10-05 18:10:44.000000000 +0100 +++ dovecot-2.2.33.2.reverse-domaincut/src/lib-mail/mail-user-hash.c 2017-11-02 16:04:03.724866755 +0000 @@ -33,9 +33,13 @@ tab = t_malloc(sizeof(static_tab)); memcpy(tab, static_tab, sizeof(static_tab)); tab[0].value = username; - tab[1].value = t_strcut(username, '@'); - tab[2].value = strchr(username, '@'); - if (tab[2].value != NULL) tab[2].value++; + tab[2].value = strrchr(username, '@'); + if (tab[2].value != NULL) { + tab[1].value = t_strdup_until(username, tab[2].value); + tab[2].value++; + } else { + tab[1].value = username; + } var_expand(str, format, tab); md5_get_digest(str_data(str), str_len(str), md5); --- dovecot-2.2.33.2/src/lib-mail/message-address.c 2017-10-05 18:10:44.000000000 +0100 +++ dovecot-2.2.33.2.reverse-domaincut/src/lib-mail/message-address.c 2017-11-02 16:00:30.926866755 +0000 @@ -540,7 +540,7 @@ if (*delimiter_string == '\0') return; - domain = strchr(address, '@'); + domain = strrchr(address, '@'); p = strstr(address, delimiter_string); if (p != NULL && (domain == NULL || p < domain)) { /* user+detail@domain */