chore: update action mailer configuration

- Set host option for action mailer to use ENV variable
- Added SSL, open timeout, and read timeout settings
- Ensure authentication method is a string

These changes streamline the action mailer configuration by introducing
additional parameters for a more secure and efficient operation,
improving overall email delivery reliability.
This commit is contained in:
songtianlun 2025-01-18 14:10:49 +08:00
parent 0b0c8587ae
commit a0122b5cea

View File

@ -59,7 +59,7 @@ Rails.application.configure do
# Set host to be used by links generated in mailer templates.
# config.action_mailer.default_url_options = { host: "example.com" }
config.action_mailer.default_url_options = ENV.fetch("RAILS_BASE_URL", "example.com")
config.action_mailer.default_url_options = { host: ENV.fetch("RAILS_BASE_URL", "example.com") }
config.action_mailer.delivery_method = :smtp
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
@ -68,7 +68,10 @@ Rails.application.configure do
password: ENV.fetch("RAILS_SMTP_PASSWORD", Rails.application.credentials.smtp.password),
address: ENV.fetch("RAILS_SMTP_HOST", Rails.application.credentials.smtp.address),
port: ENV.fetch("RAILS_SMTP_PORT", 465),
authentication: :plain
ssl: ENV.fetch("RAILS_SMTP_SSL", true),
open_timeout: 5,
read_timeout: 5,
authentication: "plain"
}
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to