In this demo, we will demonstrate the three most common sync cases, IMAP to Maildir, Maildir to IMAP, and IMAP to IMAP.
- Create email accounts
test@example.com
,test2@example.com
, andtest3@example.com
- Setup the web email client
- Login to web email client and send a few emails to
test@example.com
- Demo: Sync IMAP to Maildir (
test@example.com
to a local Maildir/mail
) - Demo: Sync Maildir to IMAP (local Maildir
/mail
totest2@example.com
) - Demo: Sync IMAP to IMAP (
test@example.com
totest3@example.com
)
To start all services, run:
docker-compose up
The following services are now running:
step-ca
as our self-signed CA to sign self-signed certs formail.example.com
used bydocker-mailserver
docker-mailserver
as mail serversnappymail
as web email clientisync
as IMAP sync client
First, in docker-mailserver
container, setup three email accounts with password test
.
echo 'test' | docker exec -i $( docker-compose ps -q docker-mailserver ) setup email add test@example.com
echo 'test' | docker exec -i $( docker-compose ps -q docker-mailserver ) setup email add test2@example.com
echo 'test' | docker exec -i $( docker-compose ps -q docker-mailserver ) setup email add test3@example.com
Then, confirm all accounts are added. You should see three accounts:
docker-compose exec docker-mailserver setup email list
Login to snappymail
Admin Panel at http://localhost:8888/?admin. Username is admin
. Get the Admin Panel password by running:
docker-compose exec snappymail cat /var/lib/snappymail/_data_/_default_/admin_password.txt
In snappymail
Admin Panel, click Domains
, and click + Add Domain
button:
- In
Name
box, enterexample.com
- Click
IMAP
tab:- In
Server
box, enterimap.example.com
- In
Secure
dropdown, selectSSL/TLS
- In
Port
, enter993
- In
Timeout
, enter300
- Uncheck
Use short login
- Uncheck
Require verification of SSL certificate
- In
- Click
SMTP
tab:- In
Server
box, entersmtp.example.com
- In
Secure
dropdown, selectSSL/TLS
- In
Port
, enter465
- In
Timeout
, enter60
- Uncheck
Use short login
- Check
Use authentication
- Check
Use login as sender
- Uncheck
Require verification of SSL certificate
- In
- At bottom right, click
Test
button:- Username:
test@example.com
- Password:
test
- Click on
Test
button. Tests should be green. ClickSave
button
- Username:
Login to snappymail
at http://localhost:8888, using username test@example.com
and password test
.
Send a few emails to yourself at test@example.com
.
In this step, we will sync test@example.com
to a local Maildir in /mail
in a docker container.
Self-signed cert of IMAP server imap.example.com
should have been created by the container entrypoint. To view self-signed cert:
docker-compose exec isync-imap-to-maildir cat /imap.example.com.pem | openssl x509 -text
/mbsyncrc
should have been created by the container entrypoint. To view /mbsyncrc
config:
docker-compose exec isync-imap-to-maildir cat /mbsyncrc
Now, run the sync (should take only 1 second):
docker-compose exec isync-imap-to-maildir /sync
To list synced files in /mail
:
docker-compose exec isync-imap-to-maildir find /mail
If you see something like the following, the sync was successful:
/mail
/mail/Trash
/mail/Trash/.uidvalidity
/mail/Trash/.mbsyncstate
/mail/Trash/tmp
/mail/Trash/cur
/mail/Trash/new
/mail/Sent
/mail/Sent/.uidvalidity
/mail/Sent/.mbsyncstate
/mail/Sent/tmp
/mail/Sent/cur
/mail/Sent/cur/1681553239.33_6.436d48e6cbdf,U=3:2,S
/mail/Sent/cur/1681553239.33_4.436d48e6cbdf,U=1:2,S
/mail/Sent/cur/1681553239.33_5.436d48e6cbdf,U=2:2,S
/mail/Sent/new
/mail/INBOX
/mail/INBOX/.uidvalidity
/mail/INBOX/.mbsyncstate
/mail/INBOX/tmp
/mail/INBOX/cur
/mail/INBOX/new
/mail/INBOX/new/1681553239.33_3.436d48e6cbdf,U=3:2,
/mail/INBOX/new/1681553239.33_2.436d48e6cbdf,U=2:2,
/mail/INBOX/new/1681553239.33_1.436d48e6cbdf,U=1:2,
/mail/Drafts
/mail/Drafts/.uidvalidity
/mail/Drafts/.mbsyncstate
/mail/Drafts/tmp
/mail/Drafts/cur
/mail/Drafts/new
/mail/Junk
/mail/Junk/.uidvalidity
/mail/Junk/.mbsyncstate
/mail/Junk/tmp
/mail/Junk/cur
/mail/Junk/new
In this step, we will sync the Maildir folder /mail
to test2@example.com
.
First, create a fresh Maildir /mail
in this container based on the previous container's Maildir /mail
:
docker exec $( docker-compose ps -q isync-imap-to-maildir ) tar -C /mail -cvf - . --exclude=.mbsyncstate --exclude=.uidvalidity | docker exec -i $( docker-compose ps -q isync-maildir-to-imap ) tar -C /mail -xvf -
Self-signed cert of IMAP server imap.example.com
should have been created by the container entrypoint. To view self-signed cert:
docker-compose exec isync-maildir-to-imap cat /imap.example.com.pem | openssl x509 -text
/mbsyncrc
should have been created by the container entrypoint. To view /mbsyncrc
config:
docker-compose exec isync-maildir-to-imap cat /mbsyncrc
Run the sync (should take only 1 second):
docker-compose exec isync-maildir-to-imap /sync
Finally, in Snappymail at http://localhost:8888, login to test2@example.com
. If you see emails present in INBOX
and SENT
, the sync was successful.
In this step, we will sync test@example.com
to test3@example.com
.
Self-signed cert of IMAP server imap.example.com
should have been created by the container entrypoint. To view self-signed cert:
docker-compose exec isync-imap-to-imap cat /imap.example.com.pem | openssl x509 -text
/mbsyncrc
should have been created by the container entrypoint. To view /mbsyncrc
config:
docker-compose exec isync-imap-to-imap cat /mbsyncrc
Run the sync (should take only 1 second):
docker-compose exec isync-imap-to-imap /sync
Finally, in Snappymail at http://localhost:8888, login to test3@example.com
. If you see emails present in INBOX
and SENT
, the sync was successful.