2023-12-07 13:52:00 +01:00
2023-12-08 14:59:17 +01:00
< img width = "800px" src = "www/src/collage-top.png" / >
2023-12-07 13:52:00 +01:00
2023-12-09 13:43:56 +01:00
# Chatmail services optimized for Delta Chat apps
2023-10-12 15:06:48 +02:00
2023-12-09 13:43:56 +01:00
This repository helps to setup a ready-to-use chatmail server
2023-10-17 00:21:32 +02:00
comprised of a minimal setup of the battle-tested
2023-11-01 19:14:48 +01:00
[postfix smtp ](https://www.postfix.org ) and [dovecot imap ](https://www.dovecot.org ) services.
2023-10-12 15:06:48 +02:00
2023-11-01 19:14:48 +01:00
The setup is designed and optimized for providing chatmail accounts
for use by [Delta Chat apps ](https://delta.chat ).
2023-10-13 16:14:11 +02:00
2023-11-01 19:14:48 +01:00
Chatmail accounts are automatically created by a first login,
after which the initially specified password is required for using them.
2023-12-09 13:43:56 +01:00
## Deploying your own chatmail server
2023-11-01 19:14:48 +01:00
2023-12-09 13:43:56 +01:00
We subsequently use `CHATMAIL_DOMAIN` as a placeholder for your fully qualified
DNS domain name (FQDN), for example `chat.example.org` .
2023-10-13 16:14:11 +02:00
2023-12-09 13:43:56 +01:00
1. Setup DNS `A` and `AAAA` records for your `CHATMAIL_DOMAIN` .
Verify that DNS is set and SSH root login works:
2023-10-13 16:14:11 +02:00
2023-12-09 13:43:56 +01:00
```
ssh root@CHATMAIL_DOMAIN
```
2023-10-24 23:21:31 +02:00
2023-12-12 21:27:16 +01:00
2. Install the `cmdeploy` command in a virtualenv
2023-10-13 16:14:11 +02:00
2023-12-09 13:43:56 +01:00
```
2023-12-12 22:38:23 +01:00
git clone https://github.com/deltachat/chatmail
cd chatmail
2023-12-12 21:18:01 +01:00
scripts/initenv.sh
2023-12-09 13:43:56 +01:00
```
2023-12-10 18:40:09 +01:00
2023-12-09 13:43:56 +01:00
3. Create chatmail configuration file `chatmail.ini` :
2023-12-07 13:52:00 +01:00
2023-12-09 13:43:56 +01:00
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy init CHATMAIL_DOMAIN
2023-12-09 13:43:56 +01:00
```
2023-11-01 19:14:48 +01:00
2023-12-09 17:45:26 +01:00
4. Deploy to the remote chatmail server:
2023-12-04 16:50:02 +01:00
2023-12-09 13:43:56 +01:00
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy run
2023-12-09 13:43:56 +01:00
```
2023-12-04 16:50:02 +01:00
2023-12-09 13:43:56 +01:00
5. To output a DNS zone file from which you can transfer DNS records
2023-12-09 17:45:26 +01:00
to your DNS provider:
2023-12-07 13:52:00 +01:00
2023-12-09 13:43:56 +01:00
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy dns
2023-12-09 13:43:56 +01:00
```
2023-12-07 13:52:00 +01:00
2023-12-10 12:52:35 +01:00
6. To check status of your remotely running chatmail service:
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy status
2023-12-10 12:52:35 +01:00
```
2023-12-10 14:38:57 +01:00
7. To test your chatmail service:
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy test
2023-12-10 14:38:57 +01:00
```
8. To benchmark your chatmail service:
2023-12-10 12:52:35 +01:00
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy bench
2023-12-10 12:52:35 +01:00
```
2023-11-01 19:14:48 +01:00
2023-12-08 14:32:40 +01:00
### Refining the web pages
```
2023-12-12 21:27:16 +01:00
scripts/cmdeploy webdev
2023-12-08 14:32:40 +01:00
```
2023-12-09 13:43:56 +01:00
This starts a local live development cycle for chatmail Web pages:
- uses the `www/src/page-layout.html` file for producing static
HTML pages from `www/src/*.md` files
2023-12-08 14:32:40 +01:00
- continously builds the web presence reading files from `www/src` directory
and generating html files and copying assets to the `www/build` directory.
- Starts a browser window automatically where you can "refresh" as needed.
2023-12-09 13:43:56 +01:00
### Home page and getting started for users
2023-12-10 14:41:20 +01:00
`cmdeploy run` sets up mail services,
2023-12-09 13:43:56 +01:00
and also creates default static Web pages and deploys them:
- a default `index.html` along with a QR code that users can click to
create accounts on your chatmail provider,
- a default `info.html` that is linked from the home page,
- a default `policy.html` that is linked from the home page.
All `.html` files are generated
by the according markdown `.md` file in the `www/src` directory.
2023-12-08 14:32:40 +01:00
2023-11-01 19:14:48 +01:00
### Ports
Postfix listens on ports 25 (smtp) and 587 (submission) and 465 (submissions).
Dovecot listens on ports 143(imap) and 993 (imaps).
Delta Chat will, however, discover all ports and configurations
automatically by reading the `autoconfig.xml` file from the chatmail instance.
## Emergency Commands to disable automatic account creation
If you need to stop account creation,
e.g. because some script is wildly creating accounts, run:
2023-11-01 21:55:15 +01:00
touch /etc/chatmail-nocreate
2023-11-01 19:14:48 +01:00
While this file is present, account creation will be blocked.
2023-10-13 17:45:54 +02:00
2023-10-17 00:21:32 +02:00
## Running tests and benchmarks (offline and online)
2023-10-13 17:45:54 +02:00
2023-10-17 00:21:32 +02:00
1. Set `CHATMAIL_SSH` so that `ssh root@$CHATMAIL_SSH` allows
to login to the chatmail instance server.
2023-10-14 11:34:09 +02:00
2023-10-17 00:21:32 +02:00
2. To run local and online tests:
2023-10-14 11:34:09 +02:00
2023-10-17 00:21:32 +02:00
scripts/test.sh
2023-10-14 11:34:09 +02:00
2023-10-17 00:21:32 +02:00
3. To run benchmarks against your chatmail instance:
2023-10-13 17:45:54 +02:00
2023-10-17 00:21:32 +02:00
scripts/bench.sh
2023-10-13 17:45:54 +02:00
2023-11-01 19:14:48 +01:00
## Development Background for chatmail instances
2023-10-13 16:14:11 +02:00
2023-11-01 19:14:48 +01:00
This repository drives the development of "chatmail instances",
comprised of minimal setups of
2023-10-12 15:06:48 +02:00
2023-11-01 19:14:48 +01:00
- [postfix smtp server ](https://www.postfix.org )
- [dovecot imap server ](https://www.dovecot.org )
2023-10-12 15:06:48 +02:00
2023-11-01 19:14:48 +01:00
as well as two custom services that are integrated with these two:
2023-10-12 15:06:48 +02:00
2023-11-14 20:38:15 +01:00
- `chatmaild/src/chatmaild/doveauth.py` implements
2023-11-01 19:14:48 +01:00
create-on-login account creation semantics and is used
by Dovecot during login authentication and by Postfix
2023-11-14 20:38:15 +01:00
which in turn uses [Dovecot SASL ](https://doc.dovecot.org/configuration_manual/authentication/dict/#complete-example-for-authenticating-via-a-unix-socket )
to authenticate users
2023-11-01 19:14:48 +01:00
to send mails for them.
- `chatmaild/src/chatmaild/filtermail.py` prevents
unencrypted e-mail from leaving the chatmail instance
and is integrated into postfix's outbound mail pipelines.
2023-10-17 19:13:30 +02:00