In reply to @juasmis:matrix.org
Hello again, first a summary of how far I've got so far:
- Setup exim in a docker container
- I can send mails from this container
1. Setup exim in a docker container
I've based myself in devture/exim-relay, but modified the conf file (find attached its configuration)
Dockerfile
FROM docker.io/alpine:3.20.2
RUN apk --no-cache add exim tini && \
mkdir /var/spool/exim && \
chmod 777 /var/spool/exim && \
ln -sf /dev/stdout /var/log/exim/mainlog && \
ln -sf /dev/stderr /var/log/exim/panic && \
ln -sf /dev/stderr /var/log/exim/reject && \
chmod 0755 /usr/sbin/exim
RUN apk --no-cache add openssl
COPY exim.conf /etc/exim/exim.conf
# Regardless of the permissions of the original `exim.conf` file in the build context,
# ensure that the `/etc/exim/exim.conf` configuration file is not writable by the Exim user.
# Otherwise, we'll get an Exim panic:
# > Exim configuration file /etc/exim/exim.conf has the wrong owner, group, or mode
RUN chmod 664 /etc/exim/exim.conf
# Generate certificates for TLS
RUN openssl req -x509 -sha256 -days 9000 -nodes -newkey rsa:4096 -keyout exim.key -out exim.crt -subj "/CN=exim-relay" && \
mv exim.crt /etc/ssl/exim.crt && \
mv exim.key /etc/ssl/exim.key
USER exim
EXPOSE 8025
ENV LOCAL_DOMAINS=@ \
RELAY_FROM_HOSTS=10.0.0.0/8:172.16.0.0/12:192.168.0.0/16 \
RELAY_TO_DOMAINS=* \
RELAY_TO_USERS= \
DISABLE_SENDER_VERIFICATION= \
HOSTNAME= \
SMARTHOST= \
SMTP_PASSWORD= \
SMTP_USERDOMAIN= \
SMTP_USERNAME=
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["exim", "-bdf", "-q15m"]
docker-compose
...
services:
exim-relay:
container_name: mobilizon-exim-relay
# image: docker.io/devture/exim-relay:4.98-r0-1
build:
context: ./exim-relay
dockerfile: Dockerfile
env_file:
- ./exim-relay/.env
user: 100:101
restart: always
networks:
- default
ports:
- "25:8025"
environment:
HOSTNAME: external.psa.es
SMARTHOST: correo.psa.es::587
SMTP_USERNAME: username@psa.es
SMTP_PASSWORD: password
SMTP_USERDOMAIN: psa.es
2. Veryfied that I can send mails from this container
echo -e "From: username@psa.es\\nSubject: test" | docker exec -i exim-relay-mobilizon exim -v jmserrano@psa.es
Does send the test emails as can be seen in the attached picture.
I think so far I managed to get the forwarding part correctly, now it only remains the mobilizon side of things, so far no lack. This is my compose, .env and config.exs:
compose
networks:
base_proxy_network:
external: true
default:
ipam:
driver: default
services:
mobilizon:
container_name: mobilizon
image: docker.io/framasoft/mobilizon:latest
restart: unless-stopped
environment:
- MOBILIZON_INSTANCE_NAME
- MOBILIZON_INSTANCE_HOST
- MOBILIZON_INSTANCE_LISTEN_IP
- MOBILIZON_INSTANCE_PORT
- MOBILIZON_INSTANCE_EMAIL
- MOBILIZON_REPLY_EMAIL
- MOBILIZON_INSTANCE_REGISTRATIONS_OPEN
- MOBILIZON_DATABASE_USERNAME=${POSTGRES_USER}
- MOBILIZON_DATABASE_PASSWORD=${POSTGRES_PASSWORD}
- MOBILIZON_DATABASE_DBNAME=${POSTGRES_DB}
- MOBILIZON_DATABASE_HOST=db
- MOBILIZON_DATABASE_PORT
- MOBILIZON_DATABASE_SSL
- MOBILIZON_INSTANCE_SECRET_KEY_BASE
- MOBILIZON_INSTANCE_SECRET_KEY
- MOBILIZON_LOGLEVEL
- MOBILIZON_SMTP_SERVER
- MOBILIZON_SMTP_PORT
- MOBILIZON_SMTP_SSL
- MOBILIZON_SMTP_TLS
- MOBILIZON_SMTP_USERNAME
- MOBILIZON_SMTP_PASSWORD
- MOBILIZON_UPLOADS
- MOBILIZON_UPLOADS_EXPORTS
- MOBILIZON_TIMEZONES_DIR
- MOBILIZON_TZDATA_DIR
volumes:
- ./uploads:/var/lib/mobilizon/uploads
- ./config.exs:/etc/mobilizon/config.exs:ro
ports:
- "4000:4000"
networks:
- base_proxy_network
- default
env_file: .env
labels:
- "traefik.enable=true"
- "traefik.http.routers.mobilizon.rule=Host(`events.psa.es`)"
- "traefik.http.routers.mobilizon.entrypoints=websecure"
- "traefik.http.routers.mobilizon.tls.certresolver=letsencryptresolver"
- "traefik.http.services.mobilizon.loadbalancer.server.port=4000"
- "traefik.http.middlewares.mobilizon-ipallowlist.ipallowlist.sourcerange=10.10.104.0/24, 10.10.105.0/24, 192.168.0.0/16, 193.146.147.128/25"
- "traefik.http.routers.mobilizon.middlewares=error-pages-middleware,mobilizon-ipallowlist"
db:
container_name: mobilizon-db
image: docker.io/postgis/postgis:15-3.4
restart: unless-stopped
volumes:
- ./db:/var/lib/postgresql/data:z
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
networks:
- default
env_file: .env
.env
######################################################
# Email settings #
######################################################
# The SMTP server
# Defaults to localhost
MOBILIZON_SMTP_SERVER=mobilizon-exim-relay
# The SMTP port
# Usual values: 25, 465, 587
# If using a local mail server, make sure the appropriate port is exposed in the docker-compose configuration as well
# Defaults to 25
MOBILIZON_SMTP_PORT=25
#
MOBILIZON_SMTP_AUTH=false
# The SMTP username
# Defaults to nil
# MOBILIZON_SMTP_USERNAME=
# The SMTP password
# Defaults to nil
# MOBILIZON_SMTP_PASSWORD=
# Whether to use SSL for SMTP.
# Boolean
# Defaults to false
MOBILIZON_SMTP_SSL=false
# Whether to use TLS for SMTP.
# Allowed values: always (TLS), never (Clear) and if_available (STARTTLS)
# Make sure to match the port value as well
# Defaults to "if_available"
MOBILIZON_SMTP_TLS=never
config.exs
config :mobilizon, Mobilizon.Web.Email.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: System.get_env("MOBILIZON_SMTP_SERVER", "localhost"),
port: System.get_env("MOBILIZON_SMTP_PORT", "25"),
username: System.get_env("MOBILIZON_SMTP_USERNAME", nil),
password: System.get_env("MOBILIZON_SMTP_PASSWORD", nil),
tls: :never,
ssl: false,
retries: 3,
no_mx_lookups: false,
auth: :never
Same unhelpful log message, also can't see anything in exim container logs:
mobilizon | 19:32:03.407 request\_id=GAMDT93\_Txa8Et4AAAZh graphql\_operation\_name=SendResetPassword \[info\] Sent 200 in 4ms
I feel like I am getting there, if you guys can help me I would really appreciate it!
I finally got the emails working by using the