first commit
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2025-07-23 21:33:16 -03:00
commit 21a35cb8e2
8 changed files with 130 additions and 0 deletions

34
.drone.yml Normal file
View File

@@ -0,0 +1,34 @@
kind: pipeline
type: docker
name: default
steps:
- name: build-and-push
image: plugins/docker
settings:
repo: registry.your-gitea.com/your-org/mail-autoconfig
tags: latest
username:
from_secret: GITEA_USERNAME
password:
from_secret: GITEA_TOKEN
- name: deploy-to-portainer
image: curlimages/curl:7.85.0
environment:
PORTAINER_URL: https://portainer.mail.mifi.holdings
PORTAINER_API_KEY:
from_secret: PORTAINER_API_KEY
ENDPOINT_ID:
from_secret: PORTAINER_ENDPOINT_ID # e.g. "1"
STACK_ID:
from_secret: PORTAINER_STACK_ID # the ID of your mailconfig stack
commands:
- >
curl -s -X POST "$PORTAINER_URL/api/stacks/$STACK_ID/file?endpointId=$ENDPOINT_ID&method=string"
-H "Authorization: Bearer $PORTAINER_API_KEY"
-F "file=@docker-compose.yml"
trigger:
branch:
- main

1
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1 @@
{}

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM python:3.11-slim
WORKDIR /app
COPY app.py templates/ ./
RUN pip install --no-cache Flask Jinja2 gunicorn
# expose port 80
CMD ["gunicorn", "-b", "0.0.0.0:80", "app:app"]

0
README.md Normal file
View File

20
app.py Normal file
View File

@@ -0,0 +1,20 @@
from flask import Flask, request, Response
import jinja2
app = Flask(__name__)
env = jinja2.Environment(
loader=jinja2.FileSystemLoader('templates'),
autoescape=jinja2.select_autoescape(['xml'])
)
@app.route('/mail/config-v1.1.xml')
def thunderbird_config():
domain = request.host.split('.', 1)[1]
xml = env.get_template('config-v1.1.xml.j2').render(DOMAIN=domain)
return Response(xml, mimetype='application/xml')
@app.route('/Autodiscover/Autodiscover.xml', methods=['POST','GET'])
def outlook_autodiscover():
domain = request.host.split('.', 1)[1]
xml = env.get_template('Autodiscover.xml.j2').render(DOMAIN=domain)
return Response(xml, mimetype='text/xml')

17
docker-compose.yml Normal file
View File

@@ -0,0 +1,17 @@
version: "3.7"
services:
mail-autoconfig:
image: git.mifi.dev/mifi-holdings/mail-autoconfig:latest
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.mailconfig.rule=HostRegexp(`{sub:autoconfig|autodiscover}.{domain:.+}`)"
- "traefik.http.routers.mailconfig.entrypoints=websecure"
- "traefik.http.routers.mailconfig.tls.certresolver=letsencrypt"
- "traefik.http.services.mailconfig.loadbalancer.server.port=80"
networks:
traefik:
external: true

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
<Response>
<Account>
<AccountType>imap</AccountType>
<Action>settings</Action>
<Protocol>
<Type>IMAP</Type>
<Server>mail.mifi.holdings</Server>
<Port>993</Port>
<DomainRequired>off</DomainRequired>
<SSL>on</SSL>
<SPA>off</SPA>
<AuthRequired>on</AuthRequired>
<LoginName>%EMAILADDRESS%</LoginName>
</Protocol>
<Protocol>
<Type>SMTP</Type>
<Server>mail.mifi.holdings</Server>
<Port>587</Port>
<DomainRequired>off</DomainRequired>
<SSL>on</SSL>
<SPA>off</SPA>
<AuthRequired>on</AuthRequired>
<LoginName>%EMAILADDRESS%</LoginName>
</Protocol>
</Account>
</Response>
</Autodiscover>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<clientConfig version="1.1">
<emailProvider id="{{ DOMAIN }}">
<domain>{{ DOMAIN }}</domain>
<incomingServer type="imap">
<hostname>mail.mifi.holdings</hostname>
<port>993</port>
<socketType>SSL</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILLOCALPART%</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>mail.mifi.holdings</hostname>
<port>587</port>
<socketType>STARTTLS</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILLOCALPART%</username>
</outgoingServer>
</emailProvider>
</clientConfig>