azure_communication_email 0.2.0 → 0.3.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7dc5641d67751daefdc4edd8e5f749235c3432fab68daa16dc5050b6d0f574d4
|
|
4
|
+
data.tar.gz: 9994f7260ac36ce4a284d0113b344f3b8a71b4cb41185b7da60f479a302d18f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5da5ad3a1cf4b559c320e3405c4d691a357e3db8fbb918aae7b6524f3b04f7b0ab97d90fa9741888d063964490293d0ebdb92f788bcc5090266f9de87394a674
|
|
7
|
+
data.tar.gz: 1de7203d9fe1bec1eb197f7bf47bc2ee31911be9f1edd7de57f51729290bb4a4327134bf9ca94fe377672e4a61d28059970c16f546a25a39da5447d42f00bcfa
|
data/README.md
CHANGED
|
@@ -16,9 +16,9 @@ Or add it manually to your Gemfile:
|
|
|
16
16
|
gem "azure_communication_email"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Configuration
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Create an Azure Communication Services resource, connect a verified email domain, and configure the delivery method in the environment where email should be sent:
|
|
22
22
|
|
|
23
23
|
```ruby
|
|
24
24
|
# config/environments/production.rb
|
|
@@ -26,13 +26,21 @@ To send emails using Azure Communication Services, configure Action Mailer with
|
|
|
26
26
|
Rails.application.configure do
|
|
27
27
|
config.action_mailer.delivery_method = :azure_communication_email
|
|
28
28
|
config.action_mailer.azure_communication_email_settings = {
|
|
29
|
-
endpoint:
|
|
30
|
-
access_key: ENV.fetch("ACS_EMAIL_ACCESS_KEY")
|
|
29
|
+
endpoint: ENV.fetch("ACS_EMAIL_ENDPOINT"),
|
|
30
|
+
access_key: ENV.fetch("ACS_EMAIL_ACCESS_KEY")
|
|
31
31
|
}
|
|
32
32
|
end
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
`endpoint` is the complete Communication Services endpoint, for example `https://my-resource.communication.azure.com`. `access_key` is one of that resource's access keys.
|
|
36
|
+
|
|
37
|
+
The optional `api_version` setting defaults to `2025-01-15-preview`. This version is used because it supports sender display names for custom domains.
|
|
38
|
+
|
|
39
|
+
Keep `config.action_mailer.delivery_method = :test` in the test environment so tests do not send real email.
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
Use Action Mailer normally; no Azure-specific mailer class is needed:
|
|
36
44
|
|
|
37
45
|
```ruby
|
|
38
46
|
class UserMailer < ApplicationMailer
|
|
@@ -43,9 +51,34 @@ class UserMailer < ApplicationMailer
|
|
|
43
51
|
end
|
|
44
52
|
```
|
|
45
53
|
|
|
54
|
+
Send through Active Job in most application code:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
UserMailer.with(user: user).welcome_email.deliver_later
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The delivery method maps Action Mailer messages to Azure, including:
|
|
61
|
+
|
|
62
|
+
- plain-text and HTML bodies, including multipart messages
|
|
63
|
+
- `to`, `cc`, `bcc`, and `reply_to` recipients with display names
|
|
64
|
+
- regular and inline attachments
|
|
65
|
+
- `X-` custom headers
|
|
66
|
+
- a sender display name when using a custom domain
|
|
67
|
+
|
|
68
|
+
Azure limits the total request size, including attachments, to 10 MB.
|
|
69
|
+
|
|
70
|
+
## Delivery status and errors
|
|
71
|
+
|
|
72
|
+
Azure accepts email asynchronously. A successful `deliver_now` or delivery job means Azure returned `202 Accepted`; it does not guarantee final delivery to the recipient. Use Azure Monitor or Event Grid email events for final delivery and bounce tracking.
|
|
73
|
+
|
|
74
|
+
Configuration errors, connection failures, timeouts, authentication failures, and non-successful HTTP responses raise `AzureCommunicationEmail::Error`. The HTTP connection timeout is 5 seconds and the response timeout is 15 seconds.
|
|
75
|
+
|
|
76
|
+
For a quick production check, send a message from the Rails console with `deliver_now`. Use a verified sender address and inspect Azure's email logs if the recipient does not receive it.
|
|
77
|
+
|
|
46
78
|
## Links
|
|
47
79
|
|
|
48
80
|
- [Service limits for Azure Communication Services](https://learn.microsoft.com/en-us/azure/communication-services/concepts/service-limits#email)
|
|
81
|
+
- [Monitor Azure Communication Services email events](https://learn.microsoft.com/en-us/azure/communication-services/concepts/email/email-event-data)
|
|
49
82
|
- [How to add and remove Multiple Sender Addresses to Email Communication Service](https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/email/add-multiple-senders?pivots=platform-azp)
|
|
50
83
|
|
|
51
84
|
## Contributing
|
|
@@ -122,11 +122,13 @@ module AzureCommunicationEmail
|
|
|
122
122
|
return [] unless @mail.attachments&.any?
|
|
123
123
|
|
|
124
124
|
@mail.attachments.map do |attachment|
|
|
125
|
-
{
|
|
125
|
+
object = {
|
|
126
126
|
"name" => attachment.filename.to_s,
|
|
127
127
|
"contentType" => attachment.mime_type.to_s,
|
|
128
128
|
"contentInBase64" => Base64.strict_encode64(attachment.body.decoded)
|
|
129
129
|
}
|
|
130
|
+
object["contentId"] = attachment.cid if attachment.inline?
|
|
131
|
+
object
|
|
130
132
|
end
|
|
131
133
|
end
|
|
132
134
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require_relative "azure_communication_email/version"
|
|
4
4
|
require_relative "azure_communication_email/delivery_method"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ActionMailer::Base.add_delivery_method :azure_communication_email, AzureCommunicationEmail::DeliveryMethod
|
|
6
|
+
ActiveSupport.on_load(:action_mailer) do
|
|
7
|
+
add_delivery_method :azure_communication_email, AzureCommunicationEmail::DeliveryMethod
|
|
9
8
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: azure_communication_email
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Devran Cosmo Uenal
|
|
@@ -95,14 +95,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
95
95
|
requirements:
|
|
96
96
|
- - ">="
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
|
-
version: 3.
|
|
98
|
+
version: 3.3.0
|
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
requirements: []
|
|
105
|
-
rubygems_version:
|
|
105
|
+
rubygems_version: 4.0.10
|
|
106
106
|
specification_version: 4
|
|
107
107
|
summary: Azure Email Communications Service Delivery Method for Action Mailer
|
|
108
108
|
test_files: []
|