autolab / Autolab

Course management service that enables auto-graded programming assignments.
http://www.autolabproject.com/
Apache License 2.0
741 stars 208 forks source link

Internal error on sending email after a new autolab installation #2168

Open abrantesasf opened 2 days ago

abrantesasf commented 2 days ago

Your environment Let us know details such as

Steps To Reproduce Steps to reproduce the behavior:

  1. Install Autolab according "Autolab + Tango Docker Compose Installation", on Autolab Docs
  2. Configure e-mail according "Mailing for Autolab Docker Installation", on Autolab Docs
  3. Test e-mail using "Forgot your password", on UVV Autolab page

Current behavior When I try to test e-mail using the "Forgot your password" feature, on https://autolab.computacaoraiz.com.br, an Error 500 Internal Server Error is triggered. Our currently email configuration, in .env file is this:

`# SMTP SETTINGS

SMTP_SETTINGS_ADDRESS=smtp.gmail.com

SMTP_SETTINGS_PORT=587

SMTP_SETTINGS_ENABLE_STARTTLS_AUTO=true

SMTP_SETTINGS_AUTHENTICATION=login

SMTP_SETTINGS_USER_NAME=our_user_name

SMTP_SETTINGS_PASSWORD=our_password

SMTP_SETTINGS_DOMAIN=computacaoraiz.com.br

SMTP_DEFAULT_FROM=autolab@computacaoraiz.com.br

HOST_PROTOCOL=http

HOST_DOMAIN=autolab.computacaoraiz.com.br`

This same configuration are working as expected on the old server, with Autolab 2.10. But, in this new server with Autolab 2.12, the same email settings are not working.

We test the email function after disabling SELinux and Firewall, but the internal error continues.

In the Autolab logs this message is displayed:

`autolab | App 191 output: W, [2024-06-30T15:29:56.977753 #191] WARN -- : An error occurred when sending a notification using 'email' notifier.Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:631:in `initialize'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:631:in `open'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:631:in `tcp_socket'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:641:in `block in do_start'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/timeout-0.4.1/lib/timeout.rb:186:in `block in timeout'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/timeout-0.4.1/lib/timeout.rb:193:in `timeout'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:640:in `do_start'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/net-smtp-0.4.0/lib/net/smtp.rb:610:in `start'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'

autolab | App 191 output: /usr/local/rvm/gems/ruby-3.2.2/gems/mail-2.8.1/lib/mail/network/delivery_methods/smtp.rb:100:in deliver!' ...

It seems the Autolab is trying to use localhost:25 instead of smtp.gmail.com:587 to send email, but the correct email settings are configured in .env file.

Expected behavior Autolab sends a email.

damianhxy commented 2 days ago

Could you try configuring Autolab via Manage Autolab > Configure Autolab > SMTP Config instead?

Screenshot 2024-06-30 at 14 46 20

With #2028, the way SMTP settings are configured was changed, looks like the documentation needs updating. Sorry for the trouble!

abrantesasf commented 2 days ago

I updated the email settings via "Manage Autolab" and now everything is working correctly. Sorry I didn't realize that the settings in this version are no longer done in the .env file. Really, the documentation needs a little updating. Thank you very much!

damianhxy commented 2 days ago

That's great to hear! We'll keep this issue open until we update the documentation.

abrantesasf commented 2 days ago

As the problem was solved, I'll close this issue. Thank you!

abrantesasf commented 2 days ago

OK, reopening the issue until the update on documentation. Thanks!

damianhxy commented 2 days ago

(For developer reference) Current mailing docs can be found at: https://docs.autolabproject.com/installation/mailing/ .env is set via: https://github.com/autolab/docker/blob/master/.env.template

Since #2028, the following vars are now read from the config file (see diff of config/environments/production.rb.template:

Thus, they should be removed from the docker .env file and the documentation updated accordingly. We might want to preserve the old documentation in a footnote in case anyone is using an older version of Autolab.

Things to note

CC @20wildmanj