Internal error on sending email after a new autolab installation
abrantesasf opened this issue ยท 8 comments
Your environment
Let us know details such as
- Universidade Vila Velha (UVV) Autolab at https://autolab.computacaoraiz.com.br
- Rocky Linux 9.4
- Autolab v2.12.0
- This is a new installation of Autolab, in a new server, to substitute our old autolab server (the old autolab is v2.10)
Steps To Reproduce
Steps to reproduce the behavior:
- Install Autolab according "Autolab + Tango Docker Compose Installation", on Autolab Docs
- Configure e-mail according "Mailing for Autolab Docker Installation", on Autolab Docs
- 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.
Could you try configuring Autolab via Manage Autolab > Configure Autolab > SMTP Config instead?
With #2028, the way SMTP settings are configured was changed, looks like the documentation needs updating. Sorry for the trouble!
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!
That's great to hear! We'll keep this issue open until we update the documentation.
As the problem was solved, I'll close this issue. Thank you!
OK, reopening the issue until the update on documentation. Thanks!
(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
:
HOST_PROTOCOL
HOST_DOMAIN
SMTP_SETTINGS_ADDRESS
SMTP_SETTINGS_PORT
SMTP_SETTINGS_ENABLE_STARTTLS_AUTO
SMTP_SETTINGS_AUTHENTICATION
SMTP_SETTINGS_USER_NAME
SMTP_SETTINGS_PASSWORD
SMTP_SETTINGS_DOMAIN
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
SMTP_DEFAULT_FROM
is still being read directly fromENV
inproduction.rb.template
, even though it appears to be written to the config file. Perhaps the code should be updated to read from the config file, and we can remove the setting from.env
. Check if this causes issues withconfig/initializers/devise.rb
which reads that env var.MAILER_HOST
(used byapplication.rb
, set in Autolab's.env.template
) seems to be redundant as it is used to setconfig.action_mailer.default_url_options
'shost
, which used to be set byHOST_DOMAIN
and now the UI. See if it can be removed -- however, the comment in.env.template
seems to suggest that it MUST have a default value. In any case, we should be able to remove the dependency onHOST_DOMAIN
even if we preserve the initialization statement inapplication.rb
.
CC @20wildmanj
Hi all,
I am encountering the same issue after configuring via Configure Autolab. The entire mailing system is not working correctly. Users are not receiving email confirmations when registering. I tested the SendGrid SMTP server and was able to trigger an email send to the desired address via telnet. To ensure that I am setting the SMTP fields correctly, I am attaching screenshots. Am I missing anything? Thanks.
Your environment:
- GCP VM with Ubuntu 22.04 installation
- Autolab v3.0.0
Steps To Reproduce:
- Install Autolab+Tango following the Docker Compose Installation steps.
- Configure SMTP mailling settings via Manage Autolab -> Configure Autolab
Hi there, tried to reproduce the issue but it seems to work fine for me, attaching screenshots of my configuration down below.
Is the email that you used under Email Defaults the email address that you used when configuring the setup for SendGrid?
Also, did you try sending a test email under configuration testing?