Configure Dovecot to only let localhost connect via imap

Solution 1:

The listen = addr:port config is deprecated in newer versions of dovecot. The new way of doing things is with service { inet_listener imap { address = ... } }.

On my system it's in /etc/dovecot/conf.d/10-master.conf:

service imap-login {
  inet_listener imap {
    address = 127.0.0.1
  }
}

Solution 2:

It's probably easiest to just listen only on localhost:

protocol imap {
    listen = 127.0.0.1:143
    ssl_listen = 127.0.0.1:993
}