Files
mail-server/README.md
2025-06-12 14:27:51 +00:00

172 lines
4.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="https://jhammah.com/wp-content/uploads/2025/06/Stalwart_logo1.png" alt="Caddy" width="500">
</picture>
</a>
</p>
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="https://jhammah.com/wp-content/uploads/2025/06/Haproxy-logo.png" alt="Caddy" width="500">
</picture>
</a>
</p>
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="https://jhammah.com/wp-content/uploads/2025/05/docker-icon.png" alt="Docker" width="175">
</picture>
</a>
</p>
<br>
<h1 align="center">Install Stalwart Mail Server and protect it with HAProxy (and Caddy) </h1>
<br>
<br>
# Navigation
- [Prerequisite](#prerequisite)
- [Install](#install)
- [Configuring docker-compose.yml file](#configuring-docker-composeyml-file)
- [Configuring stalwart.yml file](#configuring-stalwartyml-file)
- [Configuring roundcube.yml file](#configuring-roundcubeyml-file)
- [Stalwart UI First Logon and Configuration](#stalwart-ui-first-logon-and-configuration)
- [Configuring Caddyfile](#configuring-caddyfile)
- [Configuring haproxy.cfg file](#configuring-haproxycfg-file)
- [Configuring Stalwarts TOML file](#configuring-stalwart-toml-file)
- [Stalwart UI SSL and Domain Configuration](#stalwart-ui-ssl-and-domain-configuration)
- [Testing Mail Flow](#testint-mail-flow)
- [Finish](#finish)
<br>
<br>
# Prerequisite
**Here are all the things you need to make sure you have before starting this tutorial.**
- **1. You should already have Caddy installed and fully working.**
- **2. You should already have a Cloudflare account managing your domain.**
- **3. You should already have a Cloudflare API Token.**
- **4. You should already have the CNAME records 'mail.yourdomain.com' & 'webmail.yourdomain.com' created.**
- **5. You should already have your Caddyfile routing 'mail.yourdomain.com' to port 8404.**
- **6. You should already have your Caddyfile routing 'webmail.yourdomain.com' to port 680.**
- **7. You should already have an smtp2go.com account created and setup.**
- **8. You should use an advanced text editor like Notepadd++ or something like it that's designed for coding.**
- **9. You should already have ports 25, 80, 110, 143, 443, 465, 587, 993, & 4190 opened inside your router pointing to your host machine's IP address.**
<br>
<br>
# Install
<h4> This tutorial will show you how to install Stalwart Mail server as well as HAProxy so you can securely host your own email server. </h4>
<br>
<br>
<h3> 1</h3>
## Configuring docker-compose.yml file
* **This is the docker-compose.yml file that you will use to create your container. It will be installing HAProxy and then including Stalwart and Roundcube's yml files, installing them afterwards.**
* **It's always going to restart unless we manually stop it.**
* **We are mapping it to ports 25, 80, 110, 143, 443, 465, 587, 993, & 4190.**
* **We're also making HAProxy's container depend on Stalwart's container**
* **And finally we are creating a custom hao-network for these containers.**
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE " alt="Docker" width="1280">
</picture>
</a>
</p>
<br>
<br>
<h3> 2</h3>
## Configuring .env file
* **This is the .env file. Here you will want to enter your cloudflare API token as well as the email address you log into cloudflare with. This .env file will create variables that you can reference in your Caddyfile.**
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE " alt="Docker" width="1280">
</picture>
</a>
</p>
<br>
<br>
<h3> 3</h3>
## Configuring dockerfile.caddy file
* **This is the dockerfile.caddy file that your docker-compose.yml file will use to create your custom Caddy image.**
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE " alt="Docker" width="1280">
</picture>
</a>
</p>
<br>
<br>
<h3> 4</h3>
## Configuring Caddyfile
* **This is the Caddyfile. This file tells Caddy what and how to do things.**
<p align="center">
<a href="https://tip.jhammah.com">
<picture>
<img src="IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE IMAGE GOES HERE " alt="Docker" width="1280">
</picture>
</a>
</p>
<br>
<br>
# Finish
**Once you have all of the files customized to your liking and all four of them are sitting in the same directory, you'll be ready to launch the yml file.**
<br>
<H1 align="center">Support the channel so I can make more tutorials!</h1>
<H1 align="center"><a href="https://tip.jhammah.com">If this tutorial helped you out, feel free to buy me a coffee!</h1>