138 lines
2.9 KiB
Markdown
138 lines
2.9 KiB
Markdown
# Password Check Utility for Maddy
|
|
|
|
Features:
|
|
* Authenticates email accounts against the SQLite database used by Hostux panel
|
|
* Updates "last accessed" on a successful authentication
|
|
|
|
Configuration through environment variables:
|
|
* `HOSTUX_EMAIL_DATABASE_SQLITE`: required, path to the database containing the email addresses
|
|
* `HOSTUX_EMAIL_CHECKPW_LOGFILE`: if set, logs are written to the path indicated
|
|
* `HOSTUX_LOCAL_DOMAINS`: to complete `$(local_domains)` list (necessary for outbound DKIM signing, and w/ current `maddy.conf.docker`, for destination and source matching)
|
|
|
|
## Testing
|
|
|
|
### Maddy
|
|
|
|
Build the image:
|
|
```bash
|
|
podman build -t hostux/maddy:latest .
|
|
```
|
|
|
|
For `maddy.conf`:
|
|
```conf
|
|
$(hostname) = {env:MADDY_HOSTNAME}
|
|
$(primary_domain) = {env:MADDY_DOMAIN}
|
|
$(local_domains) = $(primary_domain)
|
|
|
|
tls off
|
|
|
|
auth.external hostux_auth {
|
|
helper /bin/checkpw
|
|
perdomain yes
|
|
domains $(local_domains)
|
|
}
|
|
|
|
storage.imapsql local_mailboxes {
|
|
driver sqlite3
|
|
dsn imapsql.db
|
|
}
|
|
|
|
hostname $(hostname)
|
|
|
|
table.chain local_rewrites {
|
|
optional_step regexp "(.+)\+(.+)@(.+)" "$1@$3"
|
|
optional_step static {
|
|
entry postmaster postmaster@$(primary_domain)
|
|
}
|
|
optional_step file /etc/maddy/aliases
|
|
}
|
|
|
|
msgpipeline local_routing {
|
|
destination postmaster $(local_domains) {
|
|
modify {
|
|
replace_rcpt &local_rewrites
|
|
}
|
|
|
|
deliver_to &local_mailboxes
|
|
}
|
|
|
|
default_destination {
|
|
reject 550 5.1.1 "User doesn't exist"
|
|
}
|
|
}
|
|
|
|
smtp tcp://0.0.0.0:25 {
|
|
limits {
|
|
all rate 20 1s
|
|
all concurrency 10
|
|
}
|
|
|
|
dmarc yes
|
|
check {
|
|
require_mx_record
|
|
dkim
|
|
spf
|
|
}
|
|
|
|
source $(local_domains) {
|
|
reject 501 5.1.8 "Use Submission for outgoing SMTP"
|
|
}
|
|
default_source {
|
|
destination postmaster $(local_domains) {
|
|
deliver_to &local_routing
|
|
}
|
|
default_destination {
|
|
reject 550 5.1.1 "User doesn't exist"
|
|
}
|
|
}
|
|
}
|
|
|
|
imap tcp://0.0.0.0:143 {
|
|
auth &hostux_auth
|
|
storage &local_mailboxes
|
|
}
|
|
```
|
|
|
|
```bash
|
|
podman volume create maddydata
|
|
|
|
podman run --rm \
|
|
--name maddy \
|
|
-e MADDY_HOSTNAME=mx.maddy.test \
|
|
-e MADDY_DOMAIN=maddy.test \
|
|
-e HOSTUX_EMAIL_DATABASE_SQLITE=/data/email-db/email.sqlite \
|
|
-v maddydata:/data \
|
|
-v email-db:/data/email-db/ \
|
|
-p 143:143 \
|
|
hostux/maddy:latest
|
|
|
|
podman run --rm -it -v maddydata:/data --entrypoint ash foxcpp/maddy:0.6
|
|
```
|
|
|
|
### CLI Imap Client
|
|
|
|
```bash
|
|
pip install imap-cli
|
|
export PATH="$PATH:/home/louis_guidez76/.local/bin"
|
|
```
|
|
|
|
In `~/.config/imap-cli`:
|
|
```ini
|
|
[imap]
|
|
hostname = localhost
|
|
username = louis@hostux.fr
|
|
password = ...
|
|
ssl = False
|
|
|
|
[display]
|
|
format_list =
|
|
ID: {mail_id}
|
|
Flags: {flags}
|
|
From: {from}
|
|
To: {to}
|
|
Date: {date}
|
|
Subject: {subject}
|
|
format_thread = {uid} {subject} <<< FROM {from}
|
|
format_status = {directory:>20} : {count:>5} Mails - {unseen:>5} Unseen - {recent:>5} Recent
|
|
limit = 10
|
|
```
|