Skip to content

Commit aaf8c44

Browse files
dadachiclaude
andcommitted
Replace SendGrid SMTP with Resend for transactional email
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8bd0dcf commit aaf8c44

4 files changed

Lines changed: 15 additions & 21 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ gem "valid_email2"
6060
gem "importmap-rails"
6161
gem "tailwindcss-rails", "~> 3.0"
6262
gem "rack-attack"
63+
gem "resend"
6364
# Fix LoadError: cannot load such file -- csv
6465
gem "csv", "~> 3.3"
6566

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ GEM
177177
globalid (1.3.0)
178178
activesupport (>= 6.1)
179179
hashdiff (1.2.1)
180+
httparty (0.24.2)
181+
csv
182+
mini_mime (>= 1.0.0)
183+
multi_xml (>= 0.5.2)
180184
i18n (1.14.8)
181185
concurrent-ruby (~> 1.0)
182186
image_processing (1.14.0)
@@ -244,6 +248,8 @@ GEM
244248
stimulus-rails
245249
turbo-rails
246250
msgpack (1.8.0)
251+
multi_xml (0.8.1)
252+
bigdecimal (>= 3.1, < 5)
247253
net-imap (0.6.3)
248254
date
249255
net-protocol
@@ -353,6 +359,8 @@ GEM
353359
regexp_parser (2.11.3)
354360
reline (0.6.3)
355361
io-console (~> 0.5)
362+
resend (1.0.1)
363+
httparty (>= 0.21.0)
356364
responders (3.2.0)
357365
actionpack (>= 7.0)
358366
railties (>= 7.0)
@@ -507,6 +515,7 @@ DEPENDENCIES
507515
rack-attack
508516
rack-cors
509517
rails (~> 8.1)
518+
resend
510519
rubocop-rails-omakase
511520
seed-fu (~> 2.3)
512521
selenium-webdriver (>= 4.20.1)

config/initializers/mail.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,7 @@
66
ActionMailer::Base.default_url_options[:host] = ConfigSettings.app.domain
77
ActionMailer::Base.default_url_options[:protocol] = "https"
88

9-
shared_settings = {
10-
port: 587,
11-
authentication: :plain,
12-
enable_starttls_auto: true,
13-
domain: ConfigSettings.site.domain
14-
}
15-
16-
settings = {
17-
address: Rails.application.credentials.dig(:smtp, :host),
18-
domain: Rails.application.credentials.dig(:smtp, :domain),
19-
user_name: Rails.application.credentials.dig(:smtp, :username),
20-
password: Rails.application.credentials.dig(:smtp, :password)
21-
}.merge(shared_settings)
22-
23-
ActionMailer::Base.smtp_settings.merge!(settings)
9+
ActionMailer::Base.delivery_method = :resend
10+
Resend.api_key = Rails.application.credentials.dig(:resend, :api_key)
2411
end
2512
end

lib/templates/rails/credentials/credentials.yml.tt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ active_record_encryption:
77
deterministic_key: <%= SecureRandom.alphanumeric(32) %>
88
key_derivation_salt: <%= SecureRandom.alphanumeric(32) %>
99

10-
# SMTP
11-
smtp:
12-
host:
13-
domain:
14-
username:
15-
password:
10+
# Resend
11+
resend:
12+
api_key:

0 commit comments

Comments
 (0)