- 1. Overview
- 2. Goal
- 3. Bugs, Troubleshooting, Support
- 4. Context
- 5. Installation
- 6. Legal notes
- 7. License
MDaemon is a mail and collaboration server for Microsoft Windows written in C/C++.
Caddy 2 is a powerful, cross-platform, enterprise-ready, open source web server with automatic HTTPS written in Go.
Make the configuration of MDaemon's web services easily reproducible and back-up processable, also using free SSL/TLS certificates from the Let's Encrypt project.
Caddy can request/renew Let's Encrypt and ZeroSSL certificates, but the proposed configuration is for the former, since MDaemon provides this same mechanism for creating certificates.
Unfortunately, it is not possible to provide support for the configuration and use of these scripts.
Please report any problems in the issues section on GitHub.
You can find the author and other users of MDaemon in this room where MDaemon is discussed (Matrix federation).
In the remainder of this paper, we will assume that:
- MDaemon is installed in the default directory
C:\MDAEMON:- download the MDaemon setup from this page;
- run the setup and install MDaemon: if you choose to change the installation path, remember to also change it where the default one is mentioned.
- primary and default domain is
example.com - MDaemon public host name is
mx1.example.com - MDaemon public host name for mail protocols is
mail.example.com
- Caddy is installed in the directory
C:\Program Files\Caddy:- create the
C:\Program Files\Caddydirectory; - download the Caddy binary archive from this page;
- unzip the Caddy binary archive in
C:\Program Files\Caddy; - open a command line with elevated privileges ("DOS prompt") and install Caddy as a Windows service;
- possibly define a local user under which Caddy will run and set the
relevant service to log in under that name; for complete security,
set the ACLs of the directories used by Caddy so that only that user
and users in the
.\Administratorsgroup can access them.
- create the
Two sets of files are provided. One for MDaemon that manages only one
example.com domain and one for MDaemon that manages three mail domains
example.com, example1.com, and example2.com.
As a best practice, we will keep Caddy's binary files in
C:\Program Files\Caddy separate from the configuration and accessory
files, which will be found in C:\ProgramData\Caddy.
Open a command line with elevated privileges ("DOS prompt") and execute the following commands:
mkdir C:\ProgramData\Caddy
mkdir C:\ProgramData\Caddy\Log
Depending on whether MDaemon manages a single mail domain, or multiple mail domains, copy the pair of files respectively in
assetsscriptssingle-mail-domainCaddyFilemaintenance.html
multiple-mail-domainsCaddyFilemaintenance.html
to C:\ProgramData\Caddy.
Finally, since the Caddy process searches, at start-up, for the file
CaddyFile in the same directory as the program file, it will be
necessary to create a link to the configuration file, from a command
line with elevated privileges ("DOS prompt"):
cd /D "C:\Program Files\Caddy"
mklink CaddyFile C:\ProgramData\Caddy\CaddyFile
Depending on whether MDaemon manages a single domain, or multiple
domains, change all occurrences of the example domain names
example.com, example1.com, and example2.com in the CaddyFile
and maintenance.html files to those used by MDaemon itself.
- use internal web server
- bind to 127.0.0.1
- disable Let's Encrypt request/renew scheduler
Use of the task manager is required to renew TLS/SSL certificates by Let's Encrypt used by MDaemon for mail sessions (SMTP/IMAP4/POP3).
All site certificates will instead be managed independently by Caddy.
Depending on whether MDaemon manages a single mail domain, or multiple mail domains, copy the script respectively in
assetsscriptssingle-mail-domainscheduled-renew.cmd
multiple-mail-domainsscheduled-renew.cmd
to C:\MDaemon\LetsEncrypt.
Schedule the execution of the C:\MDaemon\LetsEncrypt\scheduled-renew.cmd
script with the preferred frequency. However, it is suggested not to
deviate too much from Let's Encrypt's recommendation of no more than 60-day
between renewal attempts.
MDaemon is copyright © 1996-2023 MDaemon Technologies Ltd..
Caddy is © 2023 Stack Holdings. All rights reserved. Caddy® is a registered trademark of Stack Holdings GmbH.
Let's Encrypt is © 2023 Internet Security Research Group.
ZeroSSL is © 2023 ZeroSSL™, a product of Stack Holdings. All Rights Reserved. ZeroSSL™ is a trademark of Stack Holdings GmbH in the USA, EU & UK.
ISC License
Copyright (c) 2023 Emanuele Aliberti, MTKA
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.