{"id":20775560,"url":"https://github.com/fleaz/mdec","last_synced_at":"2025-04-30T15:47:44.483Z","repository":{"id":151252000,"uuid":"476066502","full_name":"fleaz/MDEC","owner":"fleaz","description":"Run your own E-Mail Autoconfig/Autodiscovery/Mobileconfig server for multiple domains","archived":false,"fork":false,"pushed_at":"2022-05-18T22:01:53.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-21T16:44:20.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/fleaz.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":"2022-03-30T22:08:36.000Z","updated_at":"2022-09-14T21:43:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3f1840f-55a8-4a18-8451-a1b28335d9c0","html_url":"https://github.com/fleaz/MDEC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fleaz%2FMDEC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fleaz%2FMDEC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fleaz%2FMDEC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fleaz%2FMDEC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fleaz","download_url":"https://codeload.github.com/fleaz/MDEC/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225039244,"owners_count":17411422,"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":[],"created_at":"2024-11-17T12:37:38.022Z","updated_at":"2024-11-17T12:37:38.699Z","avatar_url":"https://github.com/fleaz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mdec\nMulti Domain Email Confugration\n\n\n## Problem and requirements\nAdding a new mail account to your mail client is always way more pleasant when the client autodetects all the settings\nfor incoming and outgoing server, the port, which SSL method to use and so on. All big providers like e.g. GMail have\nthis, but most of the time when you run your own mailserver this gets left behind because it's probably not as much of a\ndeal when you just run your own mailserver for youself and run a hand full of devices that never change. But when you\nhost mail for friends and family or are like me and run a small hosting business where have have mails hosted for\ncustomers, you spend a lot of your time telling people how to configure a mailclient. This get's especially challenging\nwhen they use a client you have never touched yourself and don't know where all the settings are.  Therefore I wanted a\nrelatively simple solution that is capable of handling multiple domains. I know there exist some scripts/tools but they\nare either only good for a single domain or have to many features that I don't need and are therefore harder to setup\n(AutoMX looks like good but they need a database which I don't want to maintain just for email autodiscovery)\n\n## mdec setup\nTodo..\n\n## DNS\n### Single domain setup\nIf you want to use mdec for a single domain, let's say `example.com`, you need to add two DNS records (A,AAAA or CNAME\ndoesn't matter) which point to a webserver:\n  * autoconfig.example.com\n  * autodiscover.example.com\nThen you need to get a SSL certificate for `autodiscover.example.com`. Now scroll down to *Webserver setup* and\nconfigure the webserver to serve the XML files.\n\n### Multi domain setup\nHere comes the actual fun part. Lets say you host emails both for `example.com` and `awesome.org`. Like in the example\nabove you need one domain, lets call it the main domain, which has the actual webserver runnig which serves the mdec\ntool. We will use example.com as our main domain for this example. Configure these two DNS records:\n  * autoconfig.example.com\n  * autodiscover.example.com\n\nNow for `awesome.org` (and every other domain) we also need to add two records, but the nice part is, that no matter how\nmany domains we host, we neither have to touch the dns of our main domain, touch the webserver config or get any\nadditional SSL certificates. Neat!\n\nYou just need these two records:\n  * CNAME for `autoconfig.awesome.org` which points to `autoconfig.example.com`\n  * SRV record for `_autodiscover._tcp.awesome.org` with the value `10 0 443 autodiscover.example.com`\n\nWe can use a simple CNAME for autoconfig because it's plain HTTP so the webserver will serve our content no matter with\nwhich domain we make a request. The problem is that autodiscover on the other hand requires HTTPS, so if we would also\njust use a CNAME for the autodiscover domain, we ould need to have a valid SSL certificate for every domain we host on\nthe webserver which serves mdec. Nowadays with fancy webserves like traefik and caddy which can auto-issue new Let's\nEncrypt certificate for new domains, this theoretically isn't much of a problem anymore but I still wanted to keep\nthings simple and have a bunch of certificates just for a single autodiscover requests of a new email client seems\nbloated so I went with the SRV record method. This way we can tell the client which requested the autodiscovery service\nthat it's actually hosted on `autodiscover.example.com`. This way we get proper redirect to our main domain and only\nneed a single certificate and the webserver only needs to listen on the main domain.\n\n## Webserver setup\nTodo...\n\n\n## Configuration\nmdec is managed via the *config.yaml* file. There are some global settings to define the listening address of the tool\nand the log level as well as a entry called *domains*. This key contains a key/value pair of domain names, namely the\ndomains you host on your mailserver. Because when hosting multiple domains on the same mailerver most of the settings\nwill be the same, therefore there is a special entry with the key *default*. This entry defines the fallback values for\nall domains that are not explicitly defined in the file and also gets merged with all explicitly defined domain entries,\nso if a domain only has one different value, you just need to define it and all the other values gets inherited from the\n*default* entry.\n\n## Supported protocols\n\nLike everywhere else in IT we have [many competing standards](https://xkcd.com/927/). I tried to cover all of the\nimportant ones so this tools works for all major desktop and mobile clients. All information below is to my best\nknowledge and if something is wrong I am happy for issues of pull requests!\n\n### Autoconfig\nThis is the standard developed by Mozilla and is used e.g. in Thunderbird.  Autoconfig tries to contact\n`http://autoconfig.\u003cyour-emaildomain\u003e` and requests an XML file from `/mail/config-v1.1.xml` while providing the\nemailaddres they requested via the `emailaddress` GET-Parameter. They request only plain HTTP and don't accept a\nredirect to https so you need to deliver it plain.\n\nDocumentation for the file format can be found in the\n[Mozilla Wiki](https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat)\n\n### Autodiscover \nThis was the old standard invented by Microsoft in e.g. Outlook. From what I know this is no longer used since 2016.\nThere this is not implemented here.\n\n### Autodiscover V2\nThis is the successor to the old Autodiscover protocol. But apparantlt only supports Office365 and no longer plain IMAP\nor POP3. Therefore this can't be used for selfhosted mail servers. Thanks Microsoft!\n\n### Mobileconfig\nTodo...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffleaz%2Fmdec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffleaz%2Fmdec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffleaz%2Fmdec/lists"}