Skip to content

Commit

Permalink
Added compression to Dovecot IMAP (#13)
Browse files Browse the repository at this point in the history
* added imap compression to dovecot

* when we don't have images, we don't need to fail

* refactor zlib and imap compression

* fixed test

Co-authored-by: Istvan Szabo <[email protected]>
  • Loading branch information
sknight80 and sknight80 authored Jul 18, 2020
1 parent e7e7b37 commit 264bb88
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN apt-get update && apt-get install -y -q --no-install-recommends \
python3-pip python3-setuptools python3-wheel python3-gpg \
rsyslog dnsutils curl unbound jq rsync \
inotify-tools \
# To enable compression in imap
arj bzip2 cabextract cpio file gzip nomarch pax unzip zip \
&& rm -rf /var/spool/postfix \
&& ln -s /var/mail/postfix/spool /var/spool/postfix \
&& apt-get autoremove -y \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ init:
-docker rm -f \
mariadb postgres redis openldap \
mailserver_default mailserver_reverse mailserver_ecdsa mailserver_ldap mailserver_ldap2 \
mailserver_traefik_acmev1 mailserver_traefik_acmev2
mailserver_traefik_acmev1 mailserver_traefik_acmev2 || true

sleep 2

Expand Down
7 changes: 6 additions & 1 deletion rootfs/etc/dovecot/conf.d/10-mail.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mail_plugins = $mail_plugins quota
mail_plugins = $mail_plugins quota zlib
mail_location = maildir:/var/mail/vhosts/%d/%n/{{ .VMAIL_SUBDIR }}
maildir_stat_dirs=yes

Expand All @@ -13,3 +13,8 @@ first_valid_uid = {{ .VMAILUID }}
last_valid_uid = {{ .VMAILUID }}

mail_privileged_group = vmail

plugin {
zlib_save_level = 6 # 1..9
zlib_save = gz # or bz2, If this config entry missing, compression is disabled.
}
2 changes: 1 addition & 1 deletion rootfs/etc/dovecot/conf.d/20-imap.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ imap_idle_notify_interval = 4 mins

protocol imap {

mail_plugins = $mail_plugins imap_quota imap_sieve
mail_plugins = $mail_plugins imap_quota imap_sieve imap_zlib
imap_client_workarounds = tb-extra-mailbox-sep
mail_max_userip_connections = 20

Expand Down
6 changes: 3 additions & 3 deletions test/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1777,13 +1777,13 @@ load 'test_helper/bats-assert/load'
}

@test "checking zeyple: 3 emails encrypted in john.doe folder" {
run docker exec mailserver_reverse /bin/sh -c "grep -i 'multipart/encrypted' /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | wc -l"
run docker exec mailserver_reverse /bin/sh -c "gzip -cd /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | grep -i 'multipart/encrypted' | wc -l"
assert_success
assert_output 3
run docker exec mailserver_reverse /bin/sh -c "grep -i 'BEGIN PGP MESSAGE' /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | wc -l"
run docker exec mailserver_reverse /bin/sh -c "gzip -cd /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | grep -i 'BEGIN PGP MESSAGE' | wc -l"
assert_success
assert_output 3
run docker exec mailserver_reverse /bin/sh -c "grep -i 'END PGP MESSAGE' /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | wc -l"
run docker exec mailserver_reverse /bin/sh -c "gzip -cd /var/mail/vhosts/domain.tld/john.doe/subdir/new/* | grep -i 'END PGP MESSAGE' | wc -l"
assert_success
assert_output 3
}
Expand Down

0 comments on commit 264bb88

Please sign in to comment.