{"id":16991315,"url":"https://github.com/gmasse/emailgw","last_synced_at":"2026-05-08T14:46:09.069Z","repository":{"id":98659572,"uuid":"181330594","full_name":"gmasse/emailgw","owner":"gmasse","description":"A stateless e-mail service based on docker-mailserver","archived":false,"fork":false,"pushed_at":"2022-08-29T22:48:02.000Z","size":104,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T03:43:31.235Z","etag":null,"topics":["docker","docker-mailserver","dovecot","elasticsearch","email","imap","openstack","openstack-nova","ovhcloud"],"latest_commit_sha":null,"homepage":"https://gmasse.github.io/blog/2019/11/08/Take-control-of-your-e-mail/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmasse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-14T15:37:47.000Z","updated_at":"2021-10-28T23:12:37.000Z","dependencies_parsed_at":"2023-03-13T15:57:14.840Z","dependency_job_id":null,"html_url":"https://github.com/gmasse/emailgw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gmasse/emailgw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmasse%2Femailgw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmasse%2Femailgw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmasse%2Femailgw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmasse%2Femailgw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmasse","download_url":"https://codeload.github.com/gmasse/emailgw/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmasse%2Femailgw/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262357430,"owners_count":23298454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-mailserver","dovecot","elasticsearch","email","imap","openstack","openstack-nova","ovhcloud"],"created_at":"2024-10-14T03:25:30.124Z","updated_at":"2026-05-08T14:46:03.785Z","avatar_url":"https://github.com/gmasse.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A stateless e-mail service based on docker-mailserver\n\n[Step-by-step guide](https://gmasse.github.io/blog/2019/11/08/Take-control-of-your-e-mail/)\n\n## Further information\n\n### (Optional) Log and Metrics management\nThis is to send logs and metrics generated by the server, not the containers.\n```\nwget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -\necho \"deb https://artifacts.elastic.co/packages/7.x/apt stable main\" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list\nsudo apt-get update \u0026\u0026 sudo apt-get install filebeat\nsudo vi /etc/filebeat/filebeat.yml\nsudo systemctl enable filebeat\nsudo systemctl start filebeat\nsudo apt-get install metricbeat\nsudo vi /etc/metricbeat/metricbeat.yml\nsudo systemctl enable metricbeat\nsudo systemctl start metricbeat\n```\n\n### Maintenance\n\n#### Docecot purge\nWhen users or admin tools delete emails, the content may not be physically removed (but *only* expunged).\nYou can (should?) schedule a regular purge:\n```\ncd docker-mailserver\nsudo docker-compose exec mail doveadm purge -A\n```\nNB: it takes time, launch in a `screen` or `tmux` if you run from command line\n\n#### Backup with restic\n```\nsudo apt install restic\n\n```\n##### Local backup:\nGenerate a backup key:\n```\nsudo touch /root/.restic\nchmod 600 /root/.restic\npwgen 24 1 \u003e /root/.restic\n```\nLaunch the first backup to `/backup` directory:\n```\nsudo mkdir /backup\nsudo restic -p /root/.restic -r /backup init\nsudo restic -p /root/.restic -r /backup backup /mnt/mail/\n```\nAdd to crontab:\n```\ncat \u003c\u003cEOF | sudo tee /etc/cron.d/backup\n#\n# cron.d/backup -- schedules periodic backups\n#\n\n# m h dom mon dow user  command\n37 2 * * * root         restic -p /root/.restic -r /backup backup /mnt/mail/ ; restic -p /root/.restic -r /backup forget -l 3\nEOF\n```\n\n##### Remote (Openstack Swift) backup:\nCreate a specific Openstack user for these backup tasks.\nCreate Swift container named `backup_email` and limit rights to this user:\n```\nswift --os-region-name SBG post -r \"\u003cos_tenant_name\u003e:\u003cos_username\u003e\" backup_email\nswift --os-region-name SBG post -w \"\u003cos_tenant_name\u003e:\u003cos_username\u003e\" backup_email\n```\nGenerate a backup key if needed (see above), then launch the first remote backup:\n```\nsource .openrc\nrestic -p /root/.restic -r swift:backup_email:/ init\nrestic -p /root/.restic -r swift:backup_email:/ backup /mnt/mail/\n```\nAdd to crontab.\n\n#### Block Storage Snapshot\nSnapshot the volume:\n```\nopenstack volume snapshot create --force --volume email_storage email_storage_snap01\n```\n\n### IMAP to Dovecot Migration\n\n#### Enable IMAP Master User on SOURCE server\nCreate a Master password file `passwd.masterusers`\n```\necho 'master:'`doveadm pw -s sha512-crypt` \u003e /etc/dovecot/passwd.masterusers\n```\n\n\nTo add in `dovecot.conf` before your passdb configuration:\n```\nauth_master_user_separator = *\npassdb {\n  driver = passwd-file\n  args = /etc/dovecot/passwd.masterusers\n  master = yes\n#  result_success = continue\n}\n```\n\nReload dovecot: `doveadm reload`.\n\nYou can now connect to any IMAP account with master user/password: `myuser@mydomain.com*master`\n\n([Reference](https://doc.dovecot.org/configuration_manual/authentication/master_users/))\n\n#### Sync from source server to NEW Dovecot server\n\nAdd the follwing configuration to your target Dovecot server. `local.conf` is a good choice:\n```\nimapc_host = imap.example.com\n\n# Authenticate as masteruser / masteruser-secret, but use a separate login user.\n# If you don't have a master user, remove the imapc_master_user setting.\nimapc_user = %u\nimapc_master_user = masteruser\nimapc_password = masteruser-secret\n\nimapc_features = rfc822.size\n# If you have Dovecot v2.2.8+ you may get a significant performance improvement with fetch-headers:\n# imapc_features = $imapc_features fetch-headers\n# Read multiple mails in parallel, improves performance\nmail_prefetch_count = 20\n\n# If the old IMAP server uses INBOX. namespace prefix, set:\n#imapc_list_prefix = INBOX\n\n# for SSL:\nimapc_port = 993\nimapc_ssl = imaps\n```\n\ndoveadm -o mail_fsync=never sync -1 -R -u user@domain imapc:\n\n\nhttps://wiki2.dovecot.org/Migration/Dsync\n\n### Tips\n\nRetreiving and spam testing of an e-mail:\n```\ndoveadm fetch -u user@domain.com text HEADER Message-Id '1234@abcd' MAILBOX Inbox | su --login amavis -c 'spamassassin -d -t'\n```\n\nSize of users mailboxes:\n```\ndoveadm mailbox status -A -t vsize '*'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmasse%2Femailgw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmasse%2Femailgw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmasse%2Femailgw/lists"}