1# Dovecot23Builtin maddy IMAP server may not match your requirements in terms of4performance, reliability or anything. For this reason it is possible to5integrate it with any external IMAP server that implements necessary6protocols. Here is how to do it for Dovecot.781. Get rid of `imap` endpoint and existing `local_authdb` and `local_mailboxes`9 blocks.10112. Setup Dovecot to provide LMTP endpoint1213Here is an example configuration snippet:14```15# /etc/dovecot/dovecot.conf16protocols = imap lmtp1718# /etc/dovecot/conf.d/10-master.conf19service lmtp {20 unix_listener lmtp-maddy {21 mode = 060022 user = maddy23 }24}25```2627Add `local_mailboxes` block to maddy config using `target.lmtp` module:28```29target.lmtp local_mailboxes {30 targets unix:///var/run/dovecot/lmtp-maddy31}32```3334### Authentication3536In addition to MTA service, maddy also provides Submission service, but it37needs authentication provider data to work correctly, maddy can use Dovecot38SASL authentication protocol for it.3940You need the following in Dovecot's `10-master.conf`:41```42service auth {43 unix_listener auth-maddy-client {44 mode = 066045 user = maddy46 }47}48```4950Then just configure `dovecot_sasl` module for `submission`:51```52submission ... {53 auth dovecot_sasl unix:///var/run/dovecot/auth-maddy-client54 ... other configuration ...55}56```5758## Other IMAP servers5960Integration with other IMAP servers might be more problematic because there is61no standard protocol for authentication delegation. You might need to configure62the IMAP server to implement MSA functionality by forwarding messages to maddy63for outbound delivery. This might require more configuration changes on maddy64side since by default it will not allow relay on port 25 even for localhost65addresses. The easiest way is to create another SMTP endpoint on some port66(probably Submission port):67```68smtp tcp://127.0.0.1:587 {69 deliver_to &remote_queue70}71```72And configure IMAP server's Submission service to forward outbound messages73there.7475Depending on how Submission service is implemented you may also need to route76messages for local domains back to it via LMTP:77```78smtp tcp://127.0.0.1:587 {79 destination postmaster $(local_domains) {80 deliver_to &local_routing81 }82 default_destination {83 deliver_to &remote_queue84 }85}86```87