From d045581cb59946c47740a35860eb3e5a9aa7ab56 Mon Sep 17 00:00:00 2001 From: Mike Dalton Date: Fri, 12 Jun 2026 18:41:50 -0400 Subject: [PATCH] Send transactional email through Postmark in production Wire up Postmark as the production Action Mailer delivery method, reading the Server API token from production credentials, and set a real sender address. Development (letter_opener) and test (:test) delivery are unchanged. Co-Authored-By: Claude Opus 4.8 --- Gemfile | 3 +++ Gemfile.lock | 8 ++++++++ app/mailers/application_mailer.rb | 2 +- config/credentials/production.yml.enc | 2 +- config/environments/production.rb | 16 ++++++++-------- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 116b9bc..472e050 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,9 @@ gem "thruster", require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] gem "image_processing", "~> 1.2" +# Send transactional email through Postmark in production [https://github.com/ActiveCampaign/postmark-rails] +gem "postmark-rails", "~> 0.22" + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" diff --git a/Gemfile.lock b/Gemfile.lock index 6cd87a5..fcda66c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -248,6 +248,11 @@ GEM parser (3.3.11.1) ast (~> 2.4.1) racc + postmark (1.25.1) + json + postmark-rails (0.22.1) + actionmailer (>= 3.0.0) + postmark (>= 1.21.3, < 2.0) pp (0.6.3) prettyprint prettyprint (0.2.0) @@ -424,6 +429,7 @@ DEPENDENCIES jbuilder kamal letter_opener + postmark-rails (~> 0.22) propshaft puma (>= 5.0) rails! @@ -526,6 +532,8 @@ CHECKSUMS ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54 + postmark (1.25.1) sha256=2ac110fa1b4f85a62996fdc63167922eea1c4284a9a7ceb9e007f2758d9e17be + postmark-rails (0.22.1) sha256=fcea27dda4f7418123d7723622ec5447df4dacacc10a20a40add0f6789135d8f pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c81..e3a15d3 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" + default from: "no-reply@community-foundations.rowhomelabs.com" layout "mailer" end diff --git a/config/credentials/production.yml.enc b/config/credentials/production.yml.enc index 529adc3..898befd 100644 --- a/config/credentials/production.yml.enc +++ b/config/credentials/production.yml.enc @@ -1 +1 @@ -97luwAcQGslJIAFEcWNvbdiLnvhLy9ny+kayvBRiXK83C3BtpBFggxRuc2V4uZWeU00+PRBLPN6aQWSk/1wEtRvyl7I5eFRkS7ThCfKc51dJilEm7R2e4ENHV3pN+jQB9oxRIeKE2TYBtIZaMKpmt7bWbvpkN+9qKl0BjnIa0AbkX8/LmAzK5crUsm75HbSaW7f7244WpQ/vjWcuICH8BE+6E4MX0ketNeS9hi3YMD/Ry6vs+oSMTTb4uPT50QugZMfbSz/pLVJHKcnIUtpxmV4ocUOFCSuJOV5ehAuzDRv4au/xwvP+84/pVzenW/a61BShaS0/KziqbFD6BN99du4E4lUkb0yhHxainSIVqB1iBlV38h3iWSerytxSYTJRk7nH1dx9MxGwftdMdbNGMVygHO4HL4ppdEz6sp4=--UBnYSBFV6lXze2Ay--sDdwbw7FX5+HMnpVK/18Aw== \ No newline at end of file +e0hpSgNA6IUvDCd6Jw4R4fIlyRU3nqggi7c3/VAxfd3qq6koKDB/4Nq8HavZgiCFT0lO1WcfD7/SMtlxwsuFVLHsbrUzWNIhF0sBcegh8uk6vYM1ZteXSwcVqYqOlJmQ71nK8K0ugBl0Xg8L3OF+Bnpa6Vr7ZP/7af3Syv8nFikvlqCOb0Rh3K+sGAmKO1zEbeT9CV/z8LZsbR4RcI1sC/p2ZHCJnECgQFpwdbQ+3F9TQRgCwZAQO7J57rgzXx9fbHhIvrLZX+u4gUdKwba89Kt6Fhnc7VuEC84XvHzU5OnHJcZN4+RGeciO06b+oMhehjzNUUQdUmIf+2qC3F2M3/brVFq2tXUQvxsP0M4usnMUh9Xa26MpBZDhZIKoQZgk5GFm98TGXXtzKDVH3883GOg9QVXMdhfqqGGBgYlaUQYmO7r41Pt9EdZ4YVlxv70w/BkSHDW1f9JNVev+PHn3B3I6PQSmgJe1T+aR6VdZYGk2CQ8NSwg9C1RG--fM0xWbCXnCrb5Vho--B1KSjMxlfFxAa51y2cjxfQ== \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 7c196f8..66e7362 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -66,14 +66,14 @@ # Set host to be used by links generated in mailer templates. config.action_mailer.default_url_options = { host: "community-foundations.rowhomelabs.com" } - # Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/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 - # } + # Deliver mail through Postmark. Add the API token via + # bin/rails credentials:edit --environment=production (key: postmark.api_token) + config.action_mailer.delivery_method = :postmark + config.action_mailer.postmark_settings = { + api_token: Rails.application.credentials.dig(:postmark, :api_token) + } + # Surface delivery failures inside the Solid Queue job so they're visible and retryable. + config.action_mailer.raise_delivery_errors = true # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found).