aws-actionmailer-ses 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5155bf8bc7c5caf160e77e7768a0029fe7514e7d33d9ab14544072e64bb96cf
4
- data.tar.gz: a281ec02f365a903eade4ef008fde838b5748100211b3e2fa37aac1909d9dcff
3
+ metadata.gz: e84d63cd92cc606c4436f3f34e07e79c422b3a46f05b405ae7f2b774431781f1
4
+ data.tar.gz: b02a20505f08ecc019dd160be181eafb9b1a64567bc7abce2f8a9b26c06e631f
5
5
  SHA512:
6
- metadata.gz: c865beacd6615da65f966d7e89cf145bf301d72babec69915c7a1e74c277048d2005c86634857156f71088a37898623c8349a90f5cddd77ce20c1a38735f9ae3
7
- data.tar.gz: 2d4ebed009cc45470df4b4ab9c2258dbc8737ec00b885c34abc7b0f570165cb26f01b597c737e4cef5b206563442333f1bc02c2fac4725b78a8a7a23648e68ab
6
+ metadata.gz: fee74b70ebd190204cb83abd71e6e04b04f1495dc40f36b68fc746eaebb0c35feb48d681fb89bc185000c4c9aca48333882bf454889a8aed0cf2318f522a043e
7
+ data.tar.gz: 58692d241e18004f35b1054ceb9f28c73defb91e7f807e01dd464edde5c79bb3196bc1d9dff82bf2d2a0049df5c6e6560ac35fa238c86289691f88b13c5e3d53
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ 1.2.0 (2026-05-21)
2
+ ------------------
3
+
4
+ * Feature - Add support for `configuration_set_name` (#11), `email_tags` (#8), and `list_management_options` in SES V2 delivery settings.
5
+
6
+ 1.1.0 (2026-03-31)
7
+ ------------------
8
+
9
+ * Feature - Support injecting a preconstructed client via `:ses_client` and `:sesv2_client` options.
10
+
1
11
  1.0.0 (2024-11-21)
2
12
  ------------------
3
13
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.2.0
@@ -7,22 +7,31 @@ module Aws
7
7
  module SES
8
8
  # Provides a delivery method for ActionMailer that uses Amazon Simple Email Service.
9
9
  #
10
- # Delivery settings are used to construct a new Aws::SES::Client instance.
10
+ # Delivery settings are used to construct a new `Aws::SES::Client` instance.
11
11
  # Once you have a delivery method, you can configure your Rails environment to use it:
12
12
  #
13
13
  # config.action_mailer.delivery_method = :ses
14
14
  # config.action_mailer.ses_settings = { region: 'us-west-2' }
15
15
  #
16
+ # Alternatively, you could pass the client itself.
17
+ #
18
+ # The passed in client will be prioritized regardless of other `:ses_settings` given.
19
+ #
16
20
  # @see https://guides.rubyonrails.org/action_mailer_basics.html
17
21
  class Mailer
18
22
  attr_reader :settings
19
23
 
20
- # @param [Hash] settings Passes along initialization options to
21
- # [Aws::SES::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SES/Client.html#initialize-instance_method).
24
+ # @param [Hash] settings
25
+ # Passes along initialization options to [Aws::SES::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SES/Client.html#initialize-instance_method).
26
+ # You may pass `:ses_client` with a preconstructed {Aws::SES::Client} to reuse
27
+ # an existing instance (e.g. to avoid credential resolution on every delivery).
28
+ # When provided, the injected client is used and all other options are ignored.
22
29
  def initialize(settings = {})
23
30
  @settings = settings
24
- @client = Aws::SES::Client.new(settings)
25
- @client.config.user_agent_frameworks << 'aws-actionmailer-ses'
31
+ client_settings = settings.dup
32
+ @client = client_settings.delete(:ses_client) || Aws::SES::Client.new(client_settings)
33
+
34
+ update_user_agent
26
35
  end
27
36
 
28
37
  # Delivers a Mail::Message object. Called during mail delivery.
@@ -36,6 +45,14 @@ module Aws
36
45
  message.header[:ses_message_id] = response.message_id
37
46
  end
38
47
  end
48
+
49
+ private
50
+
51
+ def update_user_agent
52
+ return if @client.config.user_agent_frameworks.include?('aws-actionmailer-ses')
53
+
54
+ @client.config.user_agent_frameworks << 'aws-actionmailer-ses'
55
+ end
39
56
  end
40
57
  end
41
58
  end
@@ -7,26 +7,77 @@ module Aws
7
7
  module SESV2
8
8
  # Provides a delivery method for ActionMailer that uses Amazon Simple Email Service V2.
9
9
  #
10
- # Delivery settings are used to construct a new Aws::SESV2::Client instance.
11
10
  # Once you have a delivery method, you can configure your Rails environment to use it:
12
11
  #
13
12
  # config.action_mailer.delivery_method = :ses_v2
14
13
  # config.action_mailer.ses_v2_settings = { region: 'us-west-2' }
15
14
  #
15
+ # You may also pass a preconstructed client:
16
+ #
17
+ # sesv2_client = Aws::SESV2::Client.new(region: 'us-west-2')
18
+ # config.action_mailer.ses_v2_settings = { sesv2_client: sesv2_client }
19
+ #
20
+ # == SendEmail Options
21
+ #
22
+ # Settings in {SEND_EMAIL_KEYS} are forwarded directly to the
23
+ # {https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2/Client.html#send_email-instance_method SendEmail}
24
+ # API call rather than to the client constructor. They can be configured at
25
+ # any level:
26
+ #
27
+ # # Global (all emails)
28
+ # config.action_mailer.ses_v2_settings = {
29
+ # region: 'us-west-2',
30
+ # configuration_set_name: 'Production'
31
+ # }
32
+ #
33
+ # # Per-mailer class
34
+ # class MarketingMailer < ApplicationMailer
35
+ # default delivery_method_options: {
36
+ # configuration_set_name: 'Marketing',
37
+ # list_management_options: { contact_list_name: 'Promos', topic_name: 'Weekly' }
38
+ # }
39
+ # end
40
+ #
16
41
  # @see https://guides.rubyonrails.org/action_mailer_basics.html
17
42
  class Mailer
43
+ SEND_EMAIL_KEYS = %i[
44
+ configuration_set_name
45
+ email_tags
46
+ list_management_options
47
+ ].freeze
48
+
18
49
  attr_reader :settings
19
50
 
20
- # @param [Hash] settings Passes along initialization settings to
21
- # [Aws::SESV2::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2/Client.html#initialize-instance_method).
51
+ # @param [Hash] settings
52
+ # Passes along initialization settings to [Aws::SESV2::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2/Client.html#initialize-instance_method).
53
+ # You may pass `:sesv2_client` with a preconstructed {Aws::SESV2::Client} to reuse
54
+ # an existing instance (e.g. to avoid credential resolution on every delivery).
55
+ # When provided, the injected client is used and all other options are ignored.
56
+ #
57
+ # The following keys are extracted from settings and forwarded as parameters
58
+ # to the [SendEmail](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2/Client.html#send_email-instance_method)
59
+ # API call (they are not passed to the client constructor):
60
+ #
61
+ # * `:configuration_set_name` - The name of the configuration set to use for this message.
62
+ # * `:email_tags` - A list of message tags ({Types::MessageTag} hashes).
63
+ # * `:list_management_options` - A {Types::ListManagementOptions} hash for SES
64
+ # subscription management.
65
+ #
22
66
  def initialize(settings = {})
23
67
  @settings = settings
24
- @client = Aws::SESV2::Client.new(settings)
25
- @client.config.user_agent_frameworks << 'aws-actionmailer-ses'
68
+ @send_email_params = {}
69
+ client_settings = settings.dup
70
+ SEND_EMAIL_KEYS.each do |key|
71
+ value = client_settings.delete(key)
72
+ @send_email_params[key] = value if value
73
+ end
74
+ @client = client_settings.delete(:sesv2_client) || Aws::SESV2::Client.new(client_settings)
75
+
76
+ update_user_agent
26
77
  end
27
78
 
28
79
  # Delivers a Mail::Message object. Called during mail delivery.
29
- def deliver!(message)
80
+ def deliver!(message) # rubocop:disable Metrics/MethodLength
30
81
  params = { content: { raw: { data: message.to_s } } }
31
82
  params[:from_email_address] = from_email_address(message)
32
83
  params[:destination] = {
@@ -34,6 +85,7 @@ module Aws
34
85
  cc_addresses: message.cc,
35
86
  bcc_addresses: message.bcc
36
87
  }
88
+ params.merge!(@send_email_params)
37
89
 
38
90
  @client.send_email(params).tap do |response|
39
91
  message.header[:ses_message_id] = response.message_id
@@ -42,6 +94,12 @@ module Aws
42
94
 
43
95
  private
44
96
 
97
+ def update_user_agent
98
+ return if @client.config.user_agent_frameworks.include?('aws-actionmailer-ses')
99
+
100
+ @client.config.user_agent_frameworks << 'aws-actionmailer-ses'
101
+ end
102
+
45
103
  # smtp_envelope_from will default to the From address *without* sender names.
46
104
  # By omitting this param, SESv2 will correctly use sender names from the mail headers.
47
105
  # We should only use smtp_envelope_from when it was explicitly set (instance variable set)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-actionmailer-ses
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: aws-sdk-ses
@@ -81,8 +80,10 @@ files:
81
80
  homepage: https://github.com/aws/aws-actionmailer-ses-ruby
82
81
  licenses:
83
82
  - Apache-2.0
84
- metadata: {}
85
- post_install_message:
83
+ metadata:
84
+ source_code_uri: https://github.com/aws/aws-actionmailer-ses-ruby
85
+ changelog_uri: https://github.com/aws/aws-actionmailer-ses-ruby/blob/main/CHANGELOG.md
86
+ documentation_uri: https://docs.aws.amazon.com/sdk-for-ruby/aws-actionmailer-ses/api/
86
87
  rdoc_options: []
87
88
  require_paths:
88
89
  - lib
@@ -97,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  requirements: []
100
- rubygems_version: 3.5.11
101
- signing_key:
101
+ rubygems_version: 4.0.6
102
102
  specification_version: 4
103
103
  summary: ActionMailer integration with SES
104
104
  test_files: []