docker-mailserver/docs/content/config/troubleshooting/faq.md

240 lines
10 KiB
Markdown
Raw Normal View History

2016-02-01 14:02:34 +00:00
### What kind of database are you using?
None. No *sql database required.
This image is based on config files that can be versioned.
You'll probably want to `push` your config updates to your server and restart the container to apply changes.
2016-12-17 15:29:44 +00:00
### How can I sync container with host date/time?
Share the host `/etc/localtime` using:
```
volumes:
- /etc/localtime:/etc/localtime:ro
```
2016-10-11 03:25:41 +00:00
### What is the file format?
2016-04-25 04:08:46 +00:00
2016-10-11 03:25:41 +00:00
All files are using the Unix format with `LF` line endings.
Please do not use `CRLF`.
2016-04-25 04:08:46 +00:00
2016-02-01 14:02:34 +00:00
### Where are emails stored?
Mails are stored in `/var/mail/${domain}/${username}`.
2016-02-10 08:42:22 +00:00
You should use a [data volume container](https://medium.com/@ramangupta/why-docker-data-containers-are-good-589b3c6c749e#.uxyrp7xpu) for `/var/mail` to persist data. Otherwise, your data may be lost.
2016-02-10 08:36:57 +00:00
### What about backups?
2019-09-11 14:50:15 +00:00
Assuming that you use `docker-compose` and a data volumes, you can backup your user mails like this:
2016-02-10 08:36:57 +00:00
2019-09-11 14:49:25 +00:00
```
docker run --rm -ti \
2019-09-11 14:48:58 +00:00
-v maildata:/var/mail \
-v mailstate:/var/mail-state \
-v /backup/mail:/backup \
alpine:3.2 \
2019-09-11 14:50:15 +00:00
tar czf /backup/mail-`date +%y%m%d-%H%M%S`.tgz /var/mail /var/mail-state
2019-09-11 14:48:58 +00:00
2019-09-11 14:49:25 +00:00
find /backup/mail -type f -mtime +30 -exec rm -f {} \;
```
2016-02-01 14:02:34 +00:00
2019-07-24 12:31:42 +00:00
### What about `mail-state` folder?
This folder consolidates all data generated by the server itself to persist when you upgrade.
Example of data folder persisted: lib-amavis, lib-clamav, lib-fail2ban, lib-postfix, lib-postgrey, lib-spamassasin, lib-spamassassin, spool-postfix, ...
2016-02-01 14:02:34 +00:00
### How can I configure my email client?
Login are full email address (`user@domain.com`).
# imap
username: <user1@domain.tld>
password: <mypassword>
server: <mail.domain.tld>
imap port: 143 or 993 with ssl (recommended)
imap path prefix: INBOX
# smtp
smtp port: 25 or 587 with ssl (recommended)
username: <user1@domain.tld>
password: <mypassword>
2016-04-22 15:01:44 +00:00
Please use `STARTTLS`.
2016-02-01 14:02:34 +00:00
### How can I manage my custom Spamassassin rules?
2016-09-12 14:00:05 +00:00
Antispam rules are managed in `config/spamassassin-rules.cf`.
2019-03-24 17:17:35 +00:00
### What are acceptable `SA_SPAM_SUBJECT` values?
For no subject set `SA_SPAM_SUBJECT=undef`.
For a trailing white-space subject one can define the whole variable with quotes in `docker-compose.yml`:
```docker-compose
environment:
- "SA_SPAM_SUBJECT=[SPAM] "
```
2020-01-18 10:39:04 +00:00
### Can I use naked/bare domains (no host name)?
2020-01-18 11:27:45 +00:00
Yes, but not without some configuration changes. Normally it is assumed that docker-mailserver runs on a host with a name, so the fully qualified host name might be `mail.example.com` with the domain `example.com`. The MX records point to `mail.example.com`. To use a bare domain where the host name is `example.com` and the domain is also `example.com`, change mydestination from:
2020-01-18 10:39:04 +00:00
`mydestination = $myhostname, localhost.$mydomain, localhost`
To:
`mydestination = localhost.$mydomain, localhost`
2020-01-18 11:27:45 +00:00
Add the latter line to config/postfix-main.cf. That should work. Without that change there will be warnings in the logs like:
`warning: do not list domain example.com in BOTH mydestination and virtual_mailbox_domains`
Plus of course mail delivery fails.
2020-01-18 10:39:04 +00:00
### Why are Spamassassin x-headers not inserted into my sample.domain.com subdomain emails?
2017-01-29 16:45:33 +00:00
In the default setup, amavis only applies Spamassassin x-headers into domains matching the template listed in the config file 05-domain_id (in the amavis defaults). The default setup @local_domains_acl = ( ".$mydomain" ); does not match subdomains. To match subdomains, you can override the @local_domains_acl directive in the amavis user config file 50-user with @local_domains_maps = ("."); to match any sort of domain template.
2019-03-08 15:06:13 +00:00
### How can I make SpamAssassin learn spam?
2016-09-12 14:00:05 +00:00
Put received spams in `.Junk/` imap folder and add a _user_ cron like the following:
2016-09-12 14:00:05 +00:00
```
2019-03-08 15:06:13 +00:00
# This assumes you're having `environment: ONE_DIR=1` in the docker-compose.yml,
# with a consolidated config in `/var/mail-state`
#
# m h dom mon dow command
# Everyday 2:00AM, learn spam from a specific user
2017-01-05 08:06:21 +00:00
0 2 * * * docker exec mail sa-learn --spam /var/mail/domain.com/username/.Junk --dbpath /var/mail-state/lib-amavis/.spamassassin
2016-09-12 14:00:05 +00:00
```
2016-02-01 14:02:34 +00:00
If you run the server with docker-compose, you can leverage on docker configs and the mailserver's own cron. This is less problematic than the simple solution shown above, because it decouples the learning from the host on which the mailserver is running and avoids errors if the server is not running.
2019-03-12 13:44:44 +00:00
The following configuration works nicely:
create a _system_ cron file:
```sh
# in the docker-compose.yml root directory
mkdir cron
touch cron/sa-learn
chown root:root cron/sa-learn
chmod 0644 cron/sa-learn
```
2019-01-30 07:32:42 +00:00
2019-03-12 13:44:44 +00:00
edit the system cron file `nano cron/sa-learn`, and set an appropriate configuration:
```
2019-03-08 15:06:13 +00:00
# This assumes you're having `environment: ONE_DIR=1` in the docker-compose.yml,
# with a consolidated config in `/var/mail-state`
#
# m h dom mon dow user command
2019-03-12 13:44:44 +00:00
#
# Everyday 2:00AM, learn spam from a specific user
2019-03-12 13:47:08 +00:00
# spam: junk directory
0 2 * * * root sa-learn --spam /var/mail/domain.com/username/.Junk --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-03-12 13:47:08 +00:00
# ham: archive directories
15 2 * * * root sa-learn --ham /var/mail/domain.com/username/.Archive* --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-03-12 13:47:08 +00:00
# ham: inbox subdirectories
30 2 * * * root sa-learn --ham /var/mail/domain.com/username/cur* --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-03-12 13:44:44 +00:00
#
# Everyday 3:00AM, learn spam from all users of a domain
2019-03-12 13:47:08 +00:00
# spam: junk directory
0 3 * * * root sa-learn --spam /var/mail/otherdomain.com/*/.Junk --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-03-12 13:47:08 +00:00
# ham: archive directories
15 3 * * * root sa-learn --ham /var/mail/otherdomain.com/*/.Archive* --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-03-12 13:44:44 +00:00
# ham: inbox subdirectories
30 3 * * * root sa-learn --ham /var/mail/otherdomain.com/*/cur* --dbpath /var/mail-state/lib-amavis/.spamassassin
2019-01-30 07:32:42 +00:00
```
with plain docker-compose:
```docker-compose
2019-03-08 14:59:27 +00:00
version: "2"
2019-01-30 07:32:42 +00:00
services:
mail:
2019-01-30 07:32:42 +00:00
image: tvial/docker-mailserver:latest
# ...
volumes:
- ./cron/sa-learn:/etc/cron.d/sa-learn
```
with [docker swarm](https://docs.docker.com/engine/swarm/configs/):
```docker-compose
version: "3.3"
services:
mail:
image: tvial/docker-mailserver:latest
# ...
2019-01-30 07:32:42 +00:00
configs:
- source: my_sa_crontab
target: /etc/cron.d/sa-learn
2019-01-30 07:32:42 +00:00
configs:
my_sa_crontab:
file: ./cron/sa-learn
```
2019-01-30 07:32:42 +00:00
2019-01-19 11:23:27 +00:00
With the default settings, Spamassassin will require 200 mails trained for spam (for example with the method explained above) and 200 mails trained for ham (using the same command as above but using `--ham` and providing it with some ham mails). Until you provided these 200+200 mails, Spamassasin will not take the learned mails into account. For further reference, see the [Spamassassin Wiki](https://wiki.apache.org/spamassassin/BayesNotWorking).
2017-01-19 21:14:17 +00:00
2019-12-20 17:14:02 +00:00
### How can I configure a catch-all?
Considering you want to redirect all incoming e-mails for the domain `domain.tld` to `user1@domain.tld`, add the following line to `config/postfix-virtual.cf`:
```
@domain.tld user1@domain.tld
```
### How can I delete all the e-mails for a specific user?
First of all, create a special alias named `devnull` by editing `config/postfix-aliases.cf`:
```
devnull: /dev/null
```
Considering you want to delete all the e-mails received for `baduser@domain.tld`, add the following line to `config/postfix-virtual.cf`:
```
baduser@domain.tld devnull
```
2016-02-01 14:02:34 +00:00
### What kind of SSL certificates can I use?
You can use the same certificates you use with another mail server.
2016-03-04 17:56:45 +00:00
The only thing is that we provide a `self-signed` certificate tool and a `letsencrypt` certificate loader.
2016-03-04 17:57:22 +00:00
### I just moved from my old mail server but "it doesn't work".
2016-03-04 17:56:45 +00:00
If this migration implies a DNS modification, be sure to wait for DNS propagation before opening an issue.
Few examples of symptoms can be found [here](https://github.com/tomav/docker-mailserver/issues/95) or [here](https://github.com/tomav/docker-mailserver/issues/97).
2016-03-04 17:59:32 +00:00
This could be related to a modification of your `MX` record, or the IP mapped to `mail.my-domain.tld`.
If everything is OK regarding DNS, please provide [formatted logs](https://guides.github.com/features/mastering-markdown/) and config files. This will allow us to help you.
2016-09-20 14:34:48 +00:00
If we're blind, we won't be able to do anything.
### Which system requirements needs my container to run `docker-mailserver` effectively?
1 core and 1GB of RAM + swap partition is recommended to run `docker-mailserver` with clamav.
2017-08-19 08:07:20 +00:00
Otherwise, it could work with 512M of RAM.
Please note that clamav can consume a lot of memory, as it reads the entire signature database into RAM. Current figure is about 850M and growing. If you get errors about clamav or amavis failing to allocate memory you need more RAM or more swap and of course docker must be allowed to use swap (not always the case). If you can't use swap at all you may need 3G RAM.
### Is `docker-mailserver` running in a [rancher environment](http://rancher.com/rancher/)?
2017-01-09 16:39:22 +00:00
Yes, by Adding the Environment Variable `PERMIT_DOCKER: network`.
### How can I authenticate users with SMTP_ONLY?
See https://github.com/tomav/docker-mailserver/issues/1247 for an example.
2017-01-09 16:39:22 +00:00
### Common errors
```
warning: connect to Milter service inet:localhost:8893: Connection refused
# DMARC not running
# => /etc/init.d/opendmarc restart
warning: connect to Milter service inet:localhost:8891: Connection refused
# DKIM not running
# => /etc/init.d/opendkim restart
2017-08-19 08:07:20 +00:00
mail amavis[1459]: (01459-01) (!)connect to /var/run/clamav/clamd.ctl failed, attempt #1: Can't connect to a UNIX socket /var/run/clamav/clamd.ctl: No such file or directory
mail amavis[1459]: (01459-01) (!)ClamAV-clamd: All attempts (1) failed connecting to /var/run/clamav/clamd.ctl, retrying (2)
mail amavis[1459]: (01459-01) (!)ClamAV-clamscan av-scanner FAILED: /usr/bin/clamscan KILLED, signal 9 (0009) at (eval 100) line 905.
mail amavis[1459]: (01459-01) (!!)AV: ALL VIRUS SCANNERS FAILED
# Clamav is not running (not started or because you don't have enough memory)
# => check requirements and/or start Clamav
```
### What about updates
You can of course use a own script or every now and then pull && stop && rm && start the images but there are tools available for this.
There is a page in the [Update and cleanup](Update-and-cleanup) wiki page that explains how to use it the docker way.