1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Allow a self-hosted user to configure their SMTP settings directly from within the UI (#682)

* Add setting fields to model

* Allow to configure SMTP settings

* Normalize locales

* Cleanup locales

* Remove 'coming soon'

* fix test

* Reset credentials

* Reset development config

* Check smtp spelling

* Use post instead of get method

* TLS ENV variable is more descriptive

* Rework application mailer

* Follow rails convention for mailer action params

* Reset schema.rb to main

* Test WIP

* Add test for controller and mailer

* Move tests from controller to model

* Custom error message if settings are not all present

* Comment smtp config in development env

* Add default tls enabled value

* Rubocop

* Fix controller test

* Reset credentials

* Normalize locales

* Test

* fix test

* Fix application mailer test that fails randomly

* Error flash message instead of notice

* Rework application mailer tests
This commit is contained in:
Thibaut Gorioux 2024-04-29 22:44:24 +02:00 committed by GitHub
parent f0480e7ab7
commit 6fdb8e8d69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 200 additions and 15 deletions

View file

@ -23,5 +23,7 @@ module Maybe
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.action_mailer.default_options = { from: ENV["MAILER_SENDER"] }
end
end

View file

@ -38,10 +38,22 @@ Rails.application.configure do
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :letter_opener
# Uncomment to send emails in development
# config.action_mailer.raise_delivery_errors = true
# config.action_mailer.delivery_method = :smtp
# config.action_mailer.smtp_settings = {
# address: ENV["SMTP_ADDRESS"],
# port: ENV["SMTP_PORT"],
# user_name: ENV["SMTP_USERNAME"],
# password: ENV["SMTP_PASSWORD"],
# tls: ENV.fetch("SMTP_TLS_ENABLED", "true") == "true"
# }
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }

View file

@ -74,7 +74,7 @@ Rails.application.configure do
port: ENV["SMTP_PORT"],
user_name: ENV["SMTP_USERNAME"],
password: ENV["SMTP_PASSWORD"],
tls: ENV["TLS"] == "true"
tls: ENV["SMTP_TLS_ENABLED"] == "true"
}
# Ignore bad email addresses and do not raise email delivery errors.

View file

@ -0,0 +1,7 @@
---
en:
notification_mailer:
test_email:
test_email_body: Congratulation ! Connection to the SMTP server is now correctly
configured.
test_email_subject: SMTP settings verified !

View file

@ -2,7 +2,15 @@
en:
settings:
hostings:
send_test_email:
error: 'Configuration error: Test email could not be sent'
missing_smtp_setting_error: Ensure that all smtp settings are filled in
success: Test email has been sent successfully
show:
domain: App Domain
domain_placeholder: mydomain.com
email_sender: Email Sender
email_sender_placeholder: user@mydomain.com
general_settings_title: General Settings
page_title: Self-Hosting
provider_settings:
@ -13,8 +21,6 @@ en:
smtp_settings:
description: Configure outgoing mail server settings for notifications and
alerts
domain: App Domain
domain_placeholder: mydomain.com
host: SMTP Host
host_placeholder: smtp.gmail.com
password: Password
@ -24,7 +30,7 @@ en:
send_test_email: Send Test Email
send_test_email_button: Send Test Email
send_test_email_description: Verify SMTP settings by sending a test email
title: SMTP Email Configuration (coming soon...)
title: SMTP Email Configuration
username: Username
username_placeholder: username@gmail.com
upgrades:

View file

@ -15,7 +15,9 @@ Rails.application.routes.draw do
resource :preferences, only: %i[show update]
resource :notifications, only: %i[show update]
resource :billing, only: %i[show update]
resource :hosting, only: %i[show update]
resource :hosting, only: %i[show update] do
post :send_test_email, on: :collection
end
resource :security, only: %i[show update]
end