Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| computer:docker:mailserver.raphaelpiccolo.com [2025/12/27 14:26] – removed - external edit (Unknown date) 127.0.0.1 | computer:docker:mailserver.raphaelpiccolo.com [2025/12/27 14:26] (current) – ↷ Page moved from computer:debian:docker:mailserver.raphaelpiccolo.com to computer:docker:mailserver.raphaelpiccolo.com spring | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | from https:// | ||
| + | ====== complete mail server with docker ====== | ||
| + | |||
| + | the host hosting the mail server is mail.raphaelpiccolo.com | ||
| + | |||
| + | the domain is the part after the @. it means that emails will be sendable to *@raphaelpiccolo.com | ||
| + | compose | ||
| + | |||
| + | create this docker-compose.yml file : | ||
| + | |||
| + | mail: | ||
| + | image: tvial/ | ||
| + | restart: always | ||
| + | container_name: | ||
| + | ports: | ||
| + | # smtp (accept starttls) for transfer | ||
| + | - " | ||
| + | # esmtp (accept starttls) for submission | ||
| + | - " | ||
| + | # esmtp (forced encryption) for submission | ||
| + | # - " | ||
| + | # imap4 (accept starttls) for retrieval | ||
| + | - " | ||
| + | # imap4 (forced encryption) for retrieval | ||
| + | - " | ||
| + | # pop3 (accept starttls) for retrieval | ||
| + | # - " | ||
| + | # pop3 (forced encryption) for retrieval | ||
| + | # - " | ||
| + | cap_add: | ||
| + | - NET_ADMIN | ||
| + | - SYS_PTRACE | ||
| + | hostname: mail.raphaelpiccolo.com | ||
| + | domainname: raphaelpiccolo.com | ||
| + | volumes: | ||
| + | - ./ | ||
| + | - ./ | ||
| + | - ./ | ||
| + | - ./ | ||
| + | - ./ | ||
| + | environment: | ||
| + | - " | ||
| + | - " | ||
| + | |||
| + | # only useful to generate the https certificate used in mailserver | ||
| + | mailssl: | ||
| + | image: containous/ | ||
| + | container_name: | ||
| + | labels: | ||
| + | - traefik.enable=true | ||
| + | - traefik.http.routers.mail.rule=Host(`mail.raphaelpiccolo.com`) | ||
| + | - traefik.http.services.mail.loadbalancer.server.port=143 | ||
| + | - traefik.http.routers.mail.tls.certresolver=le | ||
| + | - traefik.http.routers.mail.entrypoints=websecure | ||
| + | - traefik.http.routers.mail.middlewares=securityheaders | ||
| + | |||
| + | webmail: | ||
| + | image: hardware/ | ||
| + | restart: always | ||
| + | container_name: | ||
| + | depends_on: | ||
| + | |||
| + | volumes: | ||
| + | - ./ | ||
| + | environment: | ||
| + | - LOG_TO_STDOUT=true | ||
| + | labels: | ||
| + | - traefik.enable=true | ||
| + | - traefik.http.routers.webmail.rule=Host(`webmail.raphaelpiccolo.com`) | ||
| + | - traefik.http.routers.webmail.tls.certresolver=le | ||
| + | - traefik.http.routers.webmail.entrypoints=websecure | ||
| + | - traefik.http.routers.webmail.middlewares=securityheaders | ||
| + | |||
| + | get the setup script | ||
| + | |||
| + | curl -o setup.sh https:// | ||
| + | |||
| + | check the dns of your domain : | ||
| + | |||
| + | # the A record tells what is the ip of the server | ||
| + | IN A X.X.X.X | ||
| + | mail IN A X.X.X.X | ||
| + | | ||
| + | # the mx record tells which server to call when you need to send emails ending like this @raphaelpiccolo.com | ||
| + | # they will call port 25 on this server | ||
| + | IN MX 10 mail.raphaelpiccolo.com. | ||
| + | |||
| + | ===== create an email account ===== | ||
| + | |||
| + | execute this command | ||
| + | |||
| + | bash setup.sh email add contact@raphaelpiccolo.com xxx | ||
| + | |||
| + | it will create a line in the file | ||
| + | |||
| + | emacs config/ | ||
| + | contact@raphaelpiccolo.com|xxxxxxxxxx | ||
| + | |||
| + | catchall address: | ||
| + | |||
| + | now every mails sent to *@raphaelpiccolo.com will be redirected to contact@raphaelpiccolo.com | ||
| + | |||
| + | emacs config/ | ||
| + | |||
| + | @raphaelpiccolo.com contact@raphaelpiccolo.com | ||
| + | |||
| + | ===== test working ===== | ||
| + | |||
| + | to test that local smtp is working and that the mailserver delivers the mails to the mailbox : | ||
| + | |||
| + | docker-compose up -d --force-recreate mail | ||
| + | |||
| + | swaks -t contact@raphaelpiccolo.com -f contact@raphaelpiccolo.com --header " | ||
| + | |||
| + | will show this for success | ||
| + | |||
| + | <- 250 2.0.0 Ok: queued as EEF106F804EE | ||
| + | |||
| + | you can see the delivered mail in maildata/ | ||
| + | |||
| + | you can download this mail from your phone or from a webmail. | ||
| + | do not send directly our mails to spam :) | ||
| + | |||
| + | ===== DKIM to sign the message ===== | ||
| + | |||
| + | run this to create keys | ||
| + | |||
| + | bash setup.sh config dkim | ||
| + | |||
| + | it will create this file containing what you should add in your dns | ||
| + | |||
| + | emacs ./ | ||
| + | |||
| + | then add this in dns | ||
| + | |||
| + | mail._domainkey | ||
| + | |||
| + | the spf record tells which server are authorized to send emails | ||
| + | |||
| + | authorise all the servers listed in mx. " | ||
| + | consider switching to " | ||
| + | |||
| + | IN TXT " | ||
| + | |||
| + | dmarc record uses dkim and spf for more quality | ||
| + | |||
| + | _dmarc | ||
| + | |||
| + | now you can restart and test | ||
| + | |||
| + | docker-compose up -d --force-recreate mail | ||
| + | |||
| + | ===== rainloop ===== | ||
| + | |||
| + | |||
| + | its a webmail, it connects to the server to retrieve emails. | ||
| + | (you can also configure email reception directly on your phone) | ||
| + | |||
| + | use default password to first log | ||
| + | |||
| + | https:// | ||
| + | admin | ||
| + | 12345 | ||
| + | |||
| + | then change password | ||
| + | |||
| + | then add a domain : raphaelpiccolo.com | ||
| + | |||
| + | imap: | ||
| + | server : mail.raphaelpiccolo.com | ||
| + | port: 143 | ||
| + | security : starttls | ||
| + | |||
| + | smtp | ||
| + | server : mail.raphaelpiccolo.com | ||
| + | port: 587 | ||
| + | security : starttls | ||
| + | use authentification | ||
| + | |||
| + | the whitelist can stay empty | ||
| + | |||
| + | ===== multiple domains ===== | ||
| + | |||
| + | if you want to add a new domain to the existing server | ||
| + | |||
| + | configure mx on new.com to point to raphaelpiccolo.com | ||
| + | |||
| + | add a new account for the new domain : | ||
| + | |||
| + | bash setup.sh email add contact@new.com xxx | ||
| + | |||
| + | generate dkim agaim | ||
| + | |||
| + | add dkim + spf + dmarc in your dns | ||
| + | |||
| + | generate the ssl certificate : | ||
| + | replace this line | ||
| + | |||
| + | traefik.http.routers.mail.rule=Host(`mail.raphaelpiccolo.com`) | ||
| + | |||
| + | with | ||
| + | |||
| + | traefik.http.routers.mail.rule=Host(`mail.raphaelpiccolo.com`, | ||
| + | |||
| + | |||
| + | ===== Mail Queue Management ===== | ||
| + | |||
| + | Mails von bestimmten Absendern aus der Queue löschen | ||
| + | |||
| + | for f in $(mailq | egrep " | ||
| + | |||
| + | Mails requeuen | ||
| + | |||
| + | postsuper -r < | ||