Cannot send e-mails from Redmine running in docker
Hi everyone!
I'm facing some e-mailing issue with our redmine server.
First of all, versions:
Environment: Redmine version 6.0.1.stable Ruby version 3.3.6-p108 (2024-11-05) [x86_64-linux] Rails version 7.2.2 Environment production Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp Redmine settings: Redmine theme Default SCM: Subversion 1.14.2 Mercurial 6.3.2 Bazaar 3.3.2 Git 2.39.5 Filesystem Redmine plugins: no plugin installed
I am running Redmine v6.0.1 from a docker container, using the official image:
https://hub.docker.com/_/redmine
Replies (3)
RE: Cannot send e-mails from Redmine running in docker - Added by Zs Vizi 25 days ago
For some reason the forum thought I'm spamming, therefore I must add reply by reply my problem details...
Anyway, here's my docker-compose.yml:
version: '3.1'
services:
# --- MAIN REDMINE APPLICATION ------ #
redmine_main:
container_name: redmine_main
image: redmine
restart: always
ports:
- 3000:3000
- 587:587
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
# Storage
- /usr/local/share/redmine/files:/usr/src/redmine/files
# Config files
- /usr/local/share/redmine/config/configuration.yml:/usr/src/redmine/config/configuration.yml
- /usr/local/share/redmine/config/additional_environment.rb:/usr/src/redmine/config/additional_environment.rb
# Etc.
- /usr/local/share/redmine/lib/redmine/info.rb:/usr/src/redmine/lib/redmine/info.rb
environment:
# For database
REDMINE_DB_MYSQL: redmine_mysql
REDMINE_DB_USERNAME: redmine
REDMINE_DB_PASSWORD: "aitia"
REDMINE_DB_ENCODING: utf8
# --- DATABASE FOR REDMINE ---------- #
redmine_mysql:
container_name: redmine_mysql
image: mysql:5.7
restart: always
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
MYSQL_ROOT_PASSWORD: "aitia"
MYSQL_DATABASE: redmine
MYSQL_USER: redmine
MYSQL_PASSWORD: "aitia"
volumes:
- /usr/local/share/redmine/mysql:/var/lib/mysql
Here's my nginx config:
server {
listen 443;
listen [::]:443;
ssl on;
ssl_certificate /etc/letsencrypt/live/xxxx/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxxx/privkey.pem;
include snippets/ssl-params.conf;
server_name xxxx;
# If they come here using HTTP, bounce them to the correct scheme...
error_page 497 https://xxxx;
# ...otherwise
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
server_name xxxx;
return 301 https://$host$request_uri;
}
I'm running this docker on a VM (don't ask). On both the VM and the KVM host I use UFW, on both of them ports 80, 443 and 587 are open.
Ideally we would use our Office365 mail account to send out notifications. If I set this, I get the following error...An error occurred while sending mail (Net::ReadTimeout with #<TCPSocket:(closed)>)
...with this config in configurations.yml:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.office365.com"
port: 587
authentication: :plain
expires: 60
user_name: "xxxxx@xxxx"
password: "yyyyy"
(It doesn't matter if I use :plain, :login or whatever, still the same).
If I use a dummy gmail account, I get this error...An error occurred while sending mail (execution expired)
...with this config:
enable_starttls_auto: true
address: "smtp.google.com"
port: 587
domain: "smtp.google.com"
authentication: :plain
expires: 60
user_name: "xxxx@gmail.com"
password: "yyyyy"
Still, doesn't matter if I use other authentication.
Both on google and Office365 I created the application password. I tried with the normal user password and the application password, didn't make a change. On Office365 I enabled the usage of "simple SMTP application" in the admin center.
I tried to make the logging level to DEBUG (in config/additional_info.rb), but all I get is this:
I, [2024-11-25T11:16:42.072680 #1] INFO -- : Started GET "/settings?tab=notifications" for x.x.x.x at 2024-11-25 11:16:42 +0000
I, [2024-11-25T11:16:42.073661 #1] INFO -- : Processing by SettingsController#index as HTML
I, [2024-11-25T11:16:42.073771 #1] INFO -- : Parameters: {"tab"=>"notifications"}
I, [2024-11-25T11:16:42.080957 #1] INFO -- : Current user: xxxx (id=58)
I, [2024-11-25T11:16:42.223694 #1] INFO -- : Rendered layout layouts/admin.html.erb (Duration: 140.8ms | GC: 25.8ms)
I, [2024-11-25T11:16:42.224307 #1] INFO -- : Completed 200 OK in 150ms (Views: 129.6ms | ActiveRecord: 14.7ms (21 queries, 5 cached) | GC: 25.8ms)
I am running out of ideas, especially because of the different errors with different SMTP servers. Is there any way to get more verbose logging? Am I doing something wrong on the network layer, or in the configs?
RE: Cannot send e-mails from Redmine running in docker - Added by Zs Vizi 25 days ago
If I add the ssl: true
parameter to the smtp config, the error changes to An error occurred while sending mail (SSL_connect returned=1 errno=0 peeraddr=52.98.229.178:587 state=error: wrong version number)
. Do I need some tweeking to the TLS version in some config file?
RE: Cannot send e-mails from Redmine running in docker - Added by Zs Vizi 24 days ago
Alright, so it turns out I actually forgot to add an application password in the user profile (office.com -> login -> view my profile in the right upper corner -> safety settings -> add new method -> application password), though I eventually did set the enforced MFA to the user in Entra.
It looks like it's working, so if anyone faces this issue and doesn't find useful tips (happens on this forum...), here's my config:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.office365.com"
port: 587
domain: "my.domain.com"
authentication: :login
expires: 300
user_name: "user@my.domain.com"
password: "APP_PASSWORD_HERE"
Though I'm still mad at the lack of proper error messages and logging, not in a damn eternity I would have guessed this is the problem by the 200 OK log messages and the TCP socket error...