sameersbn / docker-redmine

Docker Image for Redmine
http://www.damagehead.com/docker-redmine/
MIT License
1.27k stars 497 forks source link

SMTP on SSL/TLS (not GMail) #506

Closed galvezuma closed 2 years ago

galvezuma commented 2 years ago

I've run the docker of Redmine with options:

  --env='SMTP_USER=yyy' \
  --env='SMTP_PASS=xxx' \
  --env='SMTP_HOST=correo.uma.es' \
  --env='SMTP_PORT=587' \
  --env='SMTP_TLS=true' 

However, when Redmine sends an email it throws the error: [ActiveJob] [ActionMailer::DeliveryJob] [c3881ce3-4259-4413-8595-089dd3cdd735] Email delivery error: SSL_connect returned=1 errno=0 state=error: wrong version number I think it may be due to a wrong version of TLS protocol because the server correo.uma.es only allows TLSv1.2. Is there any way of forcing such a protocol, either by environment variables or by changing source code? Is there any way of checking which TLS version is using Redmine?

Solution

Turned out that the correc Arrguments would be

  --env='SMTP_USER=yyy' \
  --env='SMTP_PASS=xxx' \
  --env='SMTP_HOST=correo.uma.es' \
  --env='SMTP_PORT=587' \
  --env='SMTP_STARTTLS=true' \
  --env='SMTP_DOMAIN=uma.es' \
  --env='SMTP_AUTHENTICATION=:plain' \
jcormier commented 2 years ago

Reading through redmines wiki and then the actionmailer config. I dont see any reference to selecting the TLS version used. If you can figure out how to configure it. I can look into adding it as a config option in the docker.

You might have some luck asking in the redmine forum.

https://www.redmine.org/projects/redmine/wiki/emailconfiguration https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration

galvezuma commented 2 years ago

Thank you for your feedback, @jcormier. Finally, I've found that the problem was not due to the TLS version but due to a misconfiguration of the parameters. To find it, I've entered into rails (/home/redmine/redmine/bin/rails console) and followed this link to send an email, writing:

ActionMailer::Base.delivery_method = :smtp 
ActionMailer::Base.smtp_settings = {
  address: 'correo.uma.es', 
  port: 587, 
  domain: 'uma.es',
  authentication: 'plain', 
  enable_starttls_auto: true, 
  user_name: 'yyy',
  password: 'xxx'
}

ActionMailer::Base.mail(
  from: "zzz",
  to: "kkk",
  subject: "Test",
  body: "Test"
).deliver_now

Surprisingly the mail has been sent correctly, so I have tried again to run the docker with the same parameters:

  --env='SMTP_USER=yyy' \
  --env='SMTP_PASS=xxx' \
  --env='SMTP_HOST=correo.uma.es' \
  --env='SMTP_PORT=587' \
  --env='SMTP_DOMAIN=uma.es' \
  --env='SMTP_AUTHENTICATION=:plain' \
  --env='SMTP_STARTTLS=true' \

and, then, the mails are sent and the problem has vanished.

frank-dspeed commented 2 years ago

Note

Maybe the SMTP_STARTTLS and SMTP_TLS Settings should get more love in the docs.