From ae0f63546b36448d0fa1705b53a640dbcb118462 Mon Sep 17 00:00:00 2001 From: imasharc Date: Sat, 30 Aug 2025 16:27:07 +0200 Subject: [PATCH 1/2] fix(email service): Fix email service for password resets etc fix PWA javascript conflicts and email URL configuration --- Gemfile | 4 +- Gemfile.lock | 16 ++++-- app/views/layouts/application.html.erb | 80 ++++++++++++++++---------- config/deploy.yml | 2 +- config/environments/production.rb | 13 ++++- 5 files changed, 73 insertions(+), 42 deletions(-) diff --git a/Gemfile b/Gemfile index a0d9c73..e8ab036 100644 --- a/Gemfile +++ b/Gemfile @@ -24,8 +24,8 @@ gem 'devise' gem 'letter_opener', group: :development # Auto-link URLs in text gem 'rinku' -# For Production mail sending -gem 'postmark-rails' +# For Resend mail sending +gem 'resend' # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # gem "bcrypt", "~> 3.1.7" diff --git a/Gemfile.lock b/Gemfile.lock index 52c5f94..e96ba62 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,6 +100,7 @@ GEM concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) + csv (3.3.5) date (3.4.1) debug (1.11.0) irb (~> 1.10) @@ -122,6 +123,10 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) + httparty (0.23.1) + csv + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) i18n (1.14.7) concurrent-ruby (~> 1.0) importmap-rails (2.2.2) @@ -170,6 +175,8 @@ GEM mini_mime (1.1.5) minitest (5.25.5) msgpack (1.8.0) + multi_xml (0.7.2) + bigdecimal (~> 3.1) net-imap (0.5.9) date net-protocol @@ -208,11 +215,6 @@ GEM pg (1.6.1-aarch64-linux-musl) pg (1.6.1-x86_64-linux) pg (1.6.1-x86_64-linux-musl) - postmark (1.25.1) - json - postmark-rails (0.22.1) - actionmailer (>= 3.0.0) - postmark (>= 1.21.3, < 2.0) pp (0.6.2) prettyprint prettyprint (0.2.0) @@ -274,6 +276,8 @@ GEM regexp_parser (2.11.2) reline (0.6.2) io-console (~> 0.5) + resend (0.24.0) + httparty (>= 0.21.0) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) @@ -402,10 +406,10 @@ DEPENDENCIES kamal letter_opener pg (~> 1.1) - postmark-rails propshaft puma (>= 5.0) rails (~> 8.0.2) + resend rinku rubocop-rails-omakase selenium-webdriver diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2976745..c901c67 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,3 +1,4 @@ + @@ -77,43 +78,60 @@ + \ No newline at end of file diff --git a/config/deploy.yml b/config/deploy.yml index d12b695..09c7d32 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -36,7 +36,7 @@ env: secret: - RAILS_MASTER_KEY - QUICKDROP_DATABASE_PASSWORD - - POSTMARK_API_TOKEN + - RESEND_API_KEY clear: # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs. # When you start using multiple servers, you should split out job processing to a dedicated machine. diff --git a/config/environments/production.rb b/config/environments/production.rb index 2c07e6e..474d633 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,14 +62,23 @@ # config.action_mailer.raise_delivery_errors = false # Set host to be used by links generated in mailer templates. - config.action_mailer.delivery_method = :postmark + config.action_mailer.delivery_method = :resend config.action_mailer.postmark_settings = { - api_token: ENV['POSTMARK_API_TOKEN'] + api_token: ENV['RESEND_API_KEY'] } config.action_mailer.default_url_options = { host: "quickdrop.sharecon.space", protocol: 'https' } + config.action_mailer.default_options = { + from: 'noreply@quickdrop.sharecon.space' + } + + # Ensure URL helpers use correct host + Rails.application.routes.default_url_options = { + host: 'quickdrop.sharecon.space', + protocol: 'https' + } # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. # config.action_mailer.smtp_settings = { From 9352cc314e95eb48a1b90451d649bc5f5e9637e6 Mon Sep 17 00:00:00 2001 From: imasharc Date: Sat, 30 Aug 2025 17:54:19 +0200 Subject: [PATCH 2/2] fix(email config and gem): make sure to add resend gem and fix SMTP configuration --- config/environments/production.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 474d633..bd68d2c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,9 +62,15 @@ # config.action_mailer.raise_delivery_errors = false # Set host to be used by links generated in mailer templates. - config.action_mailer.delivery_method = :resend - config.action_mailer.postmark_settings = { - api_token: ENV['RESEND_API_KEY'] + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: 'smtp.resend.com', + port: 587, + domain: 'quickdrop.sharecon.space', + user_name: 'resend', + password: ENV['RESEND_API_KEY'], + authentication: 'plain', + enable_starttls_auto: true } config.action_mailer.default_url_options = { host: "quickdrop.sharecon.space",