30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/services/command_tower/messaging/execution/adapters/email/adapter.rb', line 30
def call(request:)
raise ArgumentError, "request must be an AdapterRequest" unless request.is_a?(AdapterRequest)
begin
message = Messaging::ChannelMailer.deliver_rendered(rendered: request.rendered).deliver
AdapterResult.build(
outcome: :success,
normalized_provider_status: "accepted",
provider_message_id: (message),
)
rescue ArgumentError
AdapterResult.build(
outcome: :terminal_failure,
error_code: "invalid_recipient",
)
rescue *TERMINAL_SMTP_ERRORS
AdapterResult.build(
outcome: :terminal_failure,
error_code: "smtp_rejected",
)
rescue *RETRYABLE_ERRORS
AdapterResult.build(
outcome: :retryable_failure,
error_code: "smtp_transient",
)
rescue StandardError
AdapterResult.build(
outcome: :retryable_failure,
error_code: "smtp_transient",
)
end
end
|