Skip to content

Commit 0e26f5a

Browse files
authored
Set a default from address to avoid errors (#9)
1 parent 6403a33 commit 0e26f5a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ All exceptions are reported automatically. No additional code required.
2828

2929
Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.
3030

31+
## Optional configuration
32+
33+
Set a custom from address.
34+
35+
```ruby
36+
# default: "[email protected]"
37+
config.email_error_reporter.from = "[email protected]"
38+
```
39+
3140
## Test your setup
3241

3342
You can use the built-in rake task `rake email_error_reporter:check` to check if everything works correctly in your setup.

lib/email_error_reporter/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Engine < ::Rails::Engine
44

55
config.email_error_reporter = ActiveSupport::OrderedOptions.new
66
config.email_error_reporter.to = []
7+
config.email_error_reporter.from = "[email protected]"
78

89
initializer "email_error_reporter.error_subscribe" do
910
Rails.error.subscribe(Subscriber.new)

lib/email_error_reporter/error_mailer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def error(error, handled:, severity:, context:, source: nil)
1717

1818
mail(
1919
subject: "#{severity_to_emoji.fetch(@severity)} #{error.class}",
20+
from: Rails.application.config.email_error_reporter.from,
2021
to: Rails.application.config.email_error_reporter.to
2122
)
2223
end

0 commit comments

Comments
 (0)