Setup Email Server From Scratch Debian #2 - 25 IMAPSYNC

13 Reducing Server Load With Postscreen <- Intro -> 80 Bind DNS

We believe in data independence, and support others who want data independence.
Debian Email From Scratch version 2 finished 2025-07-30.

We are still adding to it but it all works!

#################################
# Install imapsync on Debian 12 #
#     Updated on 2025-07-29     #
#################################

# Instructions here are taken directly from the Debian imapsync README

apt install -y            \
  libauthen-ntlm-perl     \
  libcgi-pm-perl          \
  libcrypt-openssl-rsa-perl   \
  libdata-uniqid-perl         \
  libencode-imaputf7-perl     \
  libfile-copy-recursive-perl \
  libfile-tail-perl        \
  libio-socket-inet6-perl  \
  libio-socket-ssl-perl    \
  libio-tee-perl           \
  libhtml-parser-perl      \
  libjson-webtoken-perl    \
  libmail-imapclient-perl  \
  libparse-recdescent-perl \
  libproc-processtable-perl \
  libmodule-scandeps-perl  \
  libreadonly-perl         \
  libregexp-common-perl    \
  libsys-meminfo-perl      \
  libterm-readkey-perl     \
  libtest-mockobject-perl  \
  libtest-pod-perl         \
  libunicode-string-perl   \
  liburi-perl              \
  libwww-perl              \
  libtest-nowarnings-perl  \
  libtest-deep-perl        \
  libtest-warn-perl        \
  make                     \
  time                     \
  cpanminus

wget -N https://imapsync.lamiral.info/imapsync
chmod +x imapsync
./imapsync
cp imapsync /usr/bin

# To use imap sync with google or microsoft aka gmail, outlook, live, or hotmail
# you may need to set an app specific password or turn off two factor authentication.

# I got my email off these services with an app specific password before they got
# too sticky but was unable to do it later, so mileage may vary.

# To use imapsync here are some examples ...

# Google To Mail Stack

.imapsync --nosyncacls --subscribe --syncinternaldates --addheader --host1 \
imap.gmail.com --user1 user1@gmail.com --password1 oldappspecificpassword --ssl1 \
--host2 mx.domain2.com -user2 user2@domain2.com -password2 mynewemailpassword --ssl2

# Hotmail To Mail Stack

imapsync --nosyncacls --subscribe --syncinternaldates --addheader --host1 \
outlook.office365.com --user1 user1@hotmail.com --password1 hotmailappspecificpassword --ssl1 \
 --host2 mx.domain2.com -user2 user2@domain2.com -password2 mynewmailpassword --ssl2

# I recently moved my email from a zimbra email service to a new one installed 
# on Debian using the tutorial from linuxbabe. This tutorial is out of date but 
# is an excellent roadmap to install and tune a mail stack from scratch.

# Zimbra To Mail Stack

imapsync --nosyncacls --subscribe --syncinternaldates --addheader --host1 \
192.168.100.1 --user1 user1@domain1.net --password1 oldemailpassword --ssl1 --host2 \ 
10.55.55.35 -user2 user1@domain2.com -password2 newmailpassword --ssl2
 

13 Reducing Server Load With Postscreen <- Intro -> 80 Bind DNS