Setup SES for production email sending

This commit is contained in:
Max Wofford 2025-03-10 11:38:42 -04:00
parent 47e52e7aa9
commit 3c2ac27cda
3 changed files with 21 additions and 15 deletions

View file

@ -22,4 +22,10 @@ SECRET_KEY_BASE=your_secret_key_base_here
ENCRYPTION_PRIMARY_KEY=generate_a_key_and_put_it_here
ENCRYPTION_DETERMINISTIC_KEY=generate_another_key_here
ENCRYPTION_KEY_DERIVATION_SALT=generate_a_salt_and_put_it_here
ENCRYPTION_KEY_DERIVATION_SALT=generate_a_salt_and_put_it_here
# By default, you don't need these for local development, as we use letter_opener
SMTP_USER_NAME=replace_with_your_smtp_username
SMTP_PASSWORD=replace_with_your_smtp_password
SMTP_ADDRESS=replace_with_your_smtp_address
SMTP_PORT=replace_with_your_smtp_port

View file

@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
default from: ENV.fetch("SMTP_FROM_EMAIL", "noreply@timedump.hackclub.com")
layout "mailer"
end

View file

@ -53,21 +53,21 @@ Rails.application.configure do
config.active_job.queue_adapter = :good_job
# config.solid_queue.connects_to = { database: { writing: :queue } }
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Configure email delivery
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
user_name: ENV.fetch("SMTP_USER_NAME"),
password: ENV.fetch("SMTP_PASSWORD"),
address: ENV.fetch("SMTP_ADDRESS"),
port: ENV.fetch("SMTP_PORT"),
authentication: :plain,
enable_starttls_auto: true
}
# Set host to be used by links generated in mailer templates.
config.action_mailer.default_url_options = { host: "example.com" }
# Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit.
# config.action_mailer.smtp_settings = {
# user_name: Rails.application.credentials.dig(:smtp, :user_name),
# password: Rails.application.credentials.dig(:smtp, :password),
# address: "smtp.example.com",
# port: 587,
# authentication: :plain
# }
config.action_mailer.default_url_options = { host: ENV.fetch("APP_HOST", "timedump.hackclub.com") }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).